CountBetween   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 47
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B shouldRun() 0 11 7
A __construct() 0 5 1
1
<?php
2
namespace pmill\RabbitRabbit\Conditions;
3
4
class CountBetween implements ConditionInterface
5
{
6
    /**
7
     * @var int
8
     */
9
    protected $from;
10
11
    /**
12
     * @var int
13
     */
14
    protected $to;
15
16
    /**
17
     * @var bool
18
     */
19
    protected $inclusive = false;
20
21
    /**
22
     * CountBetween constructor.
23
     *
24
     * @param int $from
25
     * @param int $to
26
     * @param bool $inclusive
27
     */
28 7
    public function __construct(int $from, int $to, bool $inclusive = false)
29
    {
30 7
        $this->from = $from;
31 7
        $this->to = $to;
32 7
        $this->inclusive = $inclusive;
33 7
    }
34
35
    /**
36
     * @param int $value
37
     *
38
     * @return bool
39
     */
40 7
    public function shouldRun($value)
41
    {
42 7
        if ($this->inclusive && $value >= $this->from && $value <= $this->to) {
43 2
            return true;
44
        }
45
46 5
        if (!$this->inclusive && $value > $this->from && $value < $this->to) {
47 1
            return true;
48
        }
49
50 4
        return false;
51
    }
52
}
53