1 | <?php |
||
18 | abstract class Condition |
||
19 | { |
||
20 | /** |
||
21 | * @var mixed the value to match against |
||
22 | */ |
||
23 | protected $value; |
||
24 | |||
25 | /** |
||
26 | * @var bool whether to reverse or not |
||
27 | */ |
||
28 | protected $negate = false; |
||
29 | |||
30 | /** |
||
31 | * @param mixed $value the value to match against |
||
32 | */ |
||
33 | public function __construct($value) |
||
37 | |||
38 | /** |
||
39 | * Reverses the condition |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function reverse() |
||
47 | |||
48 | /** |
||
49 | * Checks whether the value passes condition |
||
50 | * |
||
51 | * @param mixed $data the data to match |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | abstract public function matches($data); |
||
56 | |||
57 | /** |
||
58 | * Checks whether the value and the data are of same type |
||
59 | * |
||
60 | * @param mixed $value |
||
61 | * @param mixed $against |
||
62 | * |
||
63 | * @return bool true if both are of same type |
||
64 | */ |
||
65 | protected function checkType($value, $against) |
||
77 | } |
||
78 |