Composer

InstalledVersions::satisfiespublic staticWPSCache 1.0

Checks whether the given package satisfies a version constraint

e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:

Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')

Method of the class: InstalledVersions{}

No Hooks.

Returns

true|false.

Usage

$result = InstalledVersions::satisfies( $parser, $packageName, $constraint );
$parser(VersionParser) (required)
Install composer/semver to have access to this class and functionality.
$packageName(string) (required)
.
$constraint(string|null) (required)
A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package.

InstalledVersions::satisfies() code WPSCache 3.0.0

public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
    $constraint = $parser->parseConstraints((string) $constraint);
    $provided = $parser->parseConstraints(self::getVersionRanges($packageName));

    return $provided->matches($constraint);
}