function MultiConstraint::matches
Parameters
ConstraintInterface $provider:
Return value
bool
Overrides ConstraintInterface::matches
File
-
vendor/
composer/ semver/ src/ Constraint/ MultiConstraint.php, line 117
Class
- MultiConstraint
- Defines a conjunctive or disjunctive set of constraints.
Namespace
Composer\Semver\ConstraintCode
public function matches(ConstraintInterface $provider) {
if (false === $this->conjunctive) {
foreach ($this->constraints as $constraint) {
if ($provider->matches($constraint)) {
return true;
}
}
return false;
}
// when matching a conjunctive and a disjunctive multi constraint we have to iterate over the disjunctive one
// otherwise we'd return true if different parts of the disjunctive constraint match the conjunctive one
// which would lead to incorrect results, e.g. [>1 and <2] would match [<1 or >2] although they do not intersect
if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
return $provider->matches($this);
}
foreach ($this->constraints as $constraint) {
if (!$provider->matches($constraint)) {
return false;
}
}
return true;
}