1 | <?php |
||
11 | class OperationConstraint implements Constraint |
||
12 | { |
||
13 | public const OPERATOR_EQ = '='; |
||
14 | public const OPERATOR_NEQ = '!='; |
||
15 | public const OPERATOR_GT = '>'; |
||
16 | public const OPERATOR_GTE = '>='; |
||
17 | public const OPERATOR_LT = '<'; |
||
18 | public const OPERATOR_LTE = '<='; |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $operator; |
||
22 | |||
23 | /** @var Version */ |
||
24 | protected $operand; |
||
25 | |||
26 | 16 | final public function __construct(string $operator, Version $operand) |
|
33 | |||
34 | 1 | public static function equalTo(Version $operand) |
|
35 | { |
||
36 | 1 | return new static(self::OPERATOR_EQ, $operand); |
|
37 | } |
||
38 | |||
39 | public static function notEqualTo(Version $operand) |
||
43 | |||
44 | public static function greaterThan(Version $operand) |
||
48 | |||
49 | public static function greaterOrEqualTo(Version $operand) |
||
53 | |||
54 | public static function lessThan(Version $operand) |
||
58 | |||
59 | public static function lessOrEqualTo(Version $operand) |
||
63 | |||
64 | /** |
||
65 | * @param string $constraintString |
||
66 | * @return OperationConstraint|CompositeConstraint |
||
67 | */ |
||
68 | 10 | public static function fromString(string $constraintString) |
|
78 | |||
79 | 6 | public function getOperator(): string |
|
83 | |||
84 | 6 | public function getOperand(): Version |
|
88 | |||
89 | 10 | public function assert(Version $version): bool |
|
106 | |||
107 | 16 | protected function validateOperator(string $operator): void |
|
119 | } |
||
120 |