@@ 20-44 (lines=25) @@ | ||
17 | * |
|
18 | * @author Karel Osorio Ramírez <[email protected]> |
|
19 | */ |
|
20 | class Equal extends BinaryConstraintOperator |
|
21 | { |
|
22 | /** |
|
23 | * {@inheritdoc} |
|
24 | */ |
|
25 | public function evaluate($value) |
|
26 | { |
|
27 | $leftValue = $this->left()->apply($value); |
|
28 | $rightValue = $this->right()->apply($value); |
|
29 | ||
30 | if ($leftValue instanceof EquatableInterface) { |
|
31 | return $leftValue->equals($rightValue); |
|
32 | } |
|
33 | ||
34 | return $leftValue == $rightValue; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * {@inheritdoc} |
|
39 | */ |
|
40 | public function not() |
|
41 | { |
|
42 | return new NotEqual($this->left(), $this->right()); |
|
43 | } |
|
44 | } |
|
45 |
@@ 20-44 (lines=25) @@ | ||
17 | * |
|
18 | * @author Karel Osorio Ramírez <[email protected]> |
|
19 | */ |
|
20 | class NotEqual extends BinaryConstraintOperator |
|
21 | { |
|
22 | /** |
|
23 | * {@inheritdoc} |
|
24 | */ |
|
25 | public function evaluate($value) |
|
26 | { |
|
27 | $leftValue = $this->left()->apply($value); |
|
28 | $rightValue = $this->right()->apply($value); |
|
29 | ||
30 | if ($leftValue instanceof EquatableInterface) { |
|
31 | return !$leftValue->equals($rightValue); |
|
32 | } |
|
33 | ||
34 | return $leftValue != $rightValue; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * {@inheritdoc} |
|
39 | */ |
|
40 | public function not() |
|
41 | { |
|
42 | return new Equal($this->left(), $this->right()); |
|
43 | } |
|
44 | } |
|
45 |