LessThan::shouldRun()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 5

Importance

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