Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MultiConstraint.php

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\Constraint

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal