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

Breadcrumb

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

function Constraint::__construct

Same name in this branch
  1. 11.1.x vendor/symfony/validator/Constraint.php \Symfony\Component\Validator\Constraint::__construct()
  2. 11.1.x core/lib/Drupal/Core/Validation/Attribute/Constraint.php \Drupal\Core\Validation\Attribute\Constraint::__construct()
  3. 11.1.x core/lib/Drupal/Component/Version/Constraint.php \Drupal\Component\Version\Constraint::__construct()

Sets operator and version to compare with.

@phpstan-param self::STR_OP_* $operator

Parameters

string $operator:

string $version:

Throws

\InvalidArgumentException if invalid operator is given.

File

vendor/composer/semver/src/Constraint/Constraint.php, line 97

Class

Constraint
Defines a constraint.

Namespace

Composer\Semver\Constraint

Code

public function __construct($operator, $version) {
    if (!isset(self::$transOpStr[$operator])) {
        throw new \InvalidArgumentException(sprintf('Invalid operator "%s" given, expected one of: %s', $operator, implode(', ', self::getSupportedOperators())));
    }
    $this->operator = self::$transOpStr[$operator];
    $this->version = $version;
}
RSS feed
Powered by Drupal