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

Breadcrumb

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

function MultiConstraint::compile

Overrides ConstraintInterface::compile

File

vendor/composer/semver/src/Constraint/MultiConstraint.php, line 87

Class

MultiConstraint
Defines a conjunctive or disjunctive set of constraints.

Namespace

Composer\Semver\Constraint

Code

public function compile($otherOperator) {
    $parts = array();
    foreach ($this->constraints as $constraint) {
        $code = $constraint->compile($otherOperator);
        if ($code === 'true') {
            if (!$this->conjunctive) {
                return 'true';
            }
        }
        elseif ($code === 'false') {
            if ($this->conjunctive) {
                return 'false';
            }
        }
        else {
            $parts[] = '(' . $code . ')';
        }
    }
    if (!$parts) {
        return $this->conjunctive ? 'true' : 'false';
    }
    return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
}

API Navigation

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