Пример #1
0
 /**
  * @param string $constraintStringUnit
  * @return Constraint
  */
 protected function buildConstraintFromStringUnit($constraintStringUnit)
 {
     list($operator, $operandString) = array_values($this->parseConstraintStringUnit($constraintStringUnit));
     if (empty($operandString)) {
         $this->error();
     }
     try {
         return Constraint::fromProperties($operator ?: Constraint::OPERATOR_EQ, Version::fromString($operandString));
     } catch (Exception $ex) {
         $this->error();
     }
 }
Пример #2
0
 /**
  * @param ConstraintInterface|string $constraint
  * @return bool
  */
 public function matches($constraint)
 {
     if (!$constraint instanceof ConstraintInterface) {
         $constraint = Constraint::fromString($constraint);
     }
     return $constraint->assert($this);
 }