LessThan   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 40
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B shouldRun() 0 11 5
A __construct() 0 4 1
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