protected function getMostSpecificCandidate(
        array $candidates,
        string $sourceClassName,
        string $destinationClassName
    ): ?MappingInterface {
        $lowestDistance = PHP_INT_MAX;
        $selectedCandidate = null;
        /** @var MappingInterface $candidate */
        foreach($candidates as $candidate) {
            $sourceDistance = $this->getClassDistance(
                $sourceClassName,
                $candidate->getSourceClassName()
            );
            $destinationDistance = $this->getClassDistance(
                $destinationClassName,
                $candidate->getDestinationClassName()
            );
            $distance = $sourceDistance + $destinationDistance;

            if ($distance < $lowestDistance) {
                $lowestDistance = $distance;
                $selectedCandidate = $candidate;
            }
        }

        return $selectedCandidate;
    }
protected function getMostSpecificCandidate(
        array $candidates,
        string $sourceClassName,
        string $destinationClassName
    ): ?MappingInterface {
        $lowestDistance = PHP_INT_MAX;
        $selectedCandidate = null;
        /** @var MappingInterface $candidate */
        foreach($candidates as $candidate) {
            $sourceDistance = $this->getClassDistance(
                $sourceClassName,
                $candidate->getSourceClassName()
            );
            $destinationDistance = $this->getClassDistance(
                $destinationClassName,
                $candidate->getDestinationClassName()
            );
            $distance = $sourceDistance + $destinationDistance;

            if ($distance < $lowestDistance) {
                $lowestDistance = $distance;
                $selectedCandidate = $candidate;
            }
        }

        return $selectedCandidate;
    }
protected function getMostSpecificCandidate ( array $ candidates , string $ sourceClassName , string $ destinationClassName ) : ? MappingInterface { $ lowestDistance = PHP_INT_MAX ; $ selectedCandidate = null ; /** @var MappingInterface $candidate */ foreach ( $ candidates as $ candidate ) { $ sourceDistance = $ this -> getClassDistance ( $ sourceClassName , $ candidate -> getSourceClassName ( ) ) ; $ destinationDistance = $ this -> getClassDistance ( $ destinationClassName , $ candidate -> getDestinationClassName ( ) ) ; $ distance = $ sourceDistance + $ destinationDistance ; if ( $ distance < $ lowestDistance ) { $ lowestDistance = $ distance ; $ selectedCandidate = $ candidate ; } } return $ selectedCandidate ; }
Searches the most specific candidate in the list. This means the mapping
that is closest to the given source and destination in the inheritance
chain.

@param array $candidates
@param string $sourceClassName
@param string $destinationClassName
@return MappingInterface|null
Searches the most specific candidate in the list . This means the mapping that is closest to the given source and destination in the inheritance chain .