Total Complexity | 7 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class Comparator |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int |
||
10 | */ |
||
11 | protected $cmp; |
||
12 | |||
13 | /** |
||
14 | * Compare constructor. |
||
15 | * @param int $cmp |
||
16 | */ |
||
17 | public function __construct(int $cmp) |
||
18 | { |
||
19 | $this->cmp = $cmp; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @return bool |
||
24 | */ |
||
25 | public function equal(): bool |
||
26 | { |
||
27 | return $this->cmp === 0; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return bool |
||
32 | */ |
||
33 | public function notEqual(): bool |
||
34 | { |
||
35 | return !$this->cmp; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return bool |
||
40 | */ |
||
41 | public function less(): bool |
||
42 | { |
||
43 | return $this->cmp === -1; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function greater(): bool |
||
50 | { |
||
51 | return $this->cmp === 1; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return bool |
||
56 | */ |
||
57 | public function lessThanOrEqual(): bool |
||
58 | { |
||
59 | return $this->cmp < 1; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function greaterThanOrEqual(): bool |
||
68 | } |
||
69 | |||
70 | } |
||
71 |