GreaterThan::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
namespace pmill\RabbitRabbit\Conditions;
3
4
class GreaterThan implements ConditionInterface
5
{
6
    /**
7
     * @var int
8
     */
9
    protected $greaterThan;
10
11
    /**
12
     * @var bool
13
     */
14
    protected $inclusive = false;
15
16
    /**
17
     * GreaterThan constructor.
18
     *
19
     * @param int $greaterThan
20
     * @param bool $inclusive
21
     */
22 7
    public function __construct(int $greaterThan, bool $inclusive = false)
23
    {
24 7
        $this->greaterThan = $greaterThan;
25 7
        $this->inclusive = $inclusive;
26 7
    }
27
28
    /**
29
     * @param int $value
30
     *
31
     * @return bool
32
     */
33 6
    public function shouldRun($value)
34
    {
35 6
        if ($this->inclusive && $value >= $this->greaterThan) {
36 2
            return true;
37
        }
38
39 4
        if (!$this->inclusive && $value > $this->greaterThan) {
40 2
            return true;
41
        }
42
43 2
        return false;
44
    }
45
}
46