public function isPackageDependOn($packageNameA, $packageNameB)
    {
        $composerPackageA = $this->findPackageGlobal($packageNameA);

        if (is_null($composerPackageA) === true) {
            throw new \RuntimeException(sprintf('The package: "%s" does not exist.', $packageNameA));
        }

        $requires = $composerPackageA->getRequires();
        $pairPackageB = new PackageNameVersion($packageNameB);

        foreach ($requires as $link) {
            if ($link->getTarget() == $pairPackageB->getName()) {
                if ($link->getConstraint()->matches($pairPackageB->getComposerVersionConstraint())) {
                    return true;
                }

                return false;
            }
        }

        return false;
    }
public function isPackageDependOn($packageNameA, $packageNameB)
    {
        $composerPackageA = $this->findPackageGlobal($packageNameA);

        if (is_null($composerPackageA) === true) {
            throw new \RuntimeException(sprintf('The package: "%s" does not exist.', $packageNameA));
        }

        $requires = $composerPackageA->getRequires();
        $pairPackageB = new PackageNameVersion($packageNameB);

        foreach ($requires as $link) {
            if ($link->getTarget() == $pairPackageB->getName()) {
                if ($link->getConstraint()->matches($pairPackageB->getComposerVersionConstraint())) {
                    return true;
                }

                return false;
            }
        }

        return false;
    }
public function isPackageDependOn ( $ packageNameA , $ packageNameB ) { $ composerPackageA = $ this -> findPackageGlobal ( $ packageNameA ) ; if ( is_null ( $ composerPackageA ) === true ) { throw new \ RuntimeException ( sprintf ( 'The package: "%s" does not exist.' , $ packageNameA ) ) ; } $ requires = $ composerPackageA -> getRequires ( ) ; $ pairPackageB = new PackageNameVersion ( $ packageNameB ) ; foreach ( $ requires as $ link ) { if ( $ link -> getTarget ( ) == $ pairPackageB -> getName ( ) ) { if ( $ link -> getConstraint ( ) -> matches ( $ pairPackageB -> getComposerVersionConstraint ( ) ) ) { return true ; } return false ; } } return false ; }
Determines if a package A depends on package B. Only scan with first deep level.

@param string $packageNameA Packagae A. e.g: "vendor/foo *"
@param string $packageNameB Package B. e.g: "vendor/foo-b" or "vendor/foo-b >=2.0"

@return bool

@throws RuntimeException If the package doesn't exist
Determines if a package A depends on package B . Only scan with first deep level .