public function findBestCandidate($packageName, $targetPackageVersion = null)
    {
        $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
        $candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);

        if (!$candidates) {
            return false;
        }

        // select highest version if we have many
        $package = reset($candidates);
        foreach ($candidates as $candidate) {
            if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
                $package = $candidate;
            }
        }

        return $package;
    }
public function findBestCandidate($packageName, $targetPackageVersion = null)
    {
        $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
        $candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);

        if (!$candidates) {
            return false;
        }

        // select highest version if we have many
        $package = reset($candidates);
        foreach ($candidates as $candidate) {
            if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
                $package = $candidate;
            }
        }

        return $package;
    }
public function findBestCandidate ( $ packageName , $ targetPackageVersion = null ) { $ constraint = $ targetPackageVersion ? $ this -> getParser ( ) -> parseConstraints ( $ targetPackageVersion ) : null ; $ candidates = $ this -> pool -> whatProvides ( strtolower ( $ packageName ) , $ constraint , true ) ; if ( ! $ candidates ) { return false ; } // select highest version if we have many $ package = reset ( $ candidates ) ; foreach ( $ candidates as $ candidate ) { if ( version_compare ( $ package -> getVersion ( ) , $ candidate -> getVersion ( ) , '<' ) ) { $ package = $ candidate ; } } return $ package ; }
Given a package name and optional version, returns the latest PackageInterface
that matches.

@param  string                $packageName
@param  string                $targetPackageVersion
@return PackageInterface|bool
Given a package name and optional version returns the latest PackageInterface that matches .