Comparator::lessThanOrEqual()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Bavix\Geo\Comparator;
4
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
66
    {
67
        return $this->cmp > -1;
68
    }
69
70
}
71