<?php
namespace App\Services;
final class ProjectDomainMatcher {
 public function matches(string $projectDomain,string $url):bool{$host=parse_url($url,PHP_URL_HOST);if(!is_string($host)||$host==='')return false;$normalize=function(string $v):string{$v=strtolower(rtrim($v,'.'));return str_starts_with($v,'www.')?substr($v,4):$v;};$project=$normalize((string)(parse_url(str_contains($projectDomain,'://')?$projectDomain:'https://'.$projectDomain,PHP_URL_HOST)?:$projectDomain));$host=$normalize($host);return $host===$project||str_ends_with($host,'.'.$project);}
}