registry = $registry; $this->identifier = $identifier; $this->providerMap = $providerMap; $this->classifier = $classifier ?? new DomainClassifier(); } public function resolve(DomainContext $context): DomainCapabilities { $identifierType = $context->getIdentifierType(); if ($identifierType === '' || $identifierType === DomainIdentifier::UNKNOWN) { $identifierType = $this->identifier->detect($context->getInput()); } $classification = $this->classify($context, $identifierType); $domain = $classification->getDomain(); $candidateDeclarations = $this->providerMap->getCandidates($domain, $identifierType); $candidateProviders = array_column($candidateDeclarations, 'name'); $reasoning = $classification->getReasoning(); if ($candidateProviders === []) { $reasoning[] = 'No provider declaration supports both the estimated domain and identifier.'; } else { $reasoning[] = 'Providers ranked by declared priority and confidence.'; } return new DomainCapabilities( $identifierType, $domain, $candidateProviders, $classification->getConfidence(), $reasoning, $classification->getEvidence(), $classification->getAlternativeDomains() ); } private function classify(DomainContext $context, string $identifierType): DomainCapabilities { $domainHint = $context->getDomainHint(); if ($domainHint !== null && $this->registry->has($domainHint)) { $definition = $this->registry->get($domainHint); return new DomainCapabilities( $identifierType, $definition['name'], [], 1.0, ['Domain selected from an explicit registered hint.'], [new DomainEvidence('category', $domainHint, $definition['name'], 1.0, 'Explicit domain hint matched.')] ); } return $this->classifier->classify(DomainSignals::fromContext($context, $identifierType)); } }