Completed
Push — master ( 6a6c7b...f57853 )
by Sebastian
03:30
created

Between::test()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Linna Filter
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2017, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types = 1);
11
12
namespace Linna\Filter\Rules;
13
14
use Linna\Filter\RuleInterface;
15
16
/**
17
 * Check if value is between a intervall.
18
 */
19
class Between implements RuleInterface
20
{
21
    /**
22
     * @var mixed Received value.
23
     */
24
    private $received;
25
    
26
    /**
27
     * @var mixed Min expected value.
28
     */
29
    private $min;
30
    
31
    /**
32
     * @var mixed Max expected value.
33
     */
34
    private $max;
35
36
    /**
37
     * Class constructor.
38
     *
39
     * @param mixed $received
40
     * @param mixed $min
41
     * @param mixed $max
42
     */
43
    public function __construct($received, $min, $max)
44
    {
45
        $this->received = $received;
46
        $this->min = $min;
47
        $this->max = $max;
48
    }
49
50
    /**
51
     * Test.
52
     *
53
     * @return bool
54
     */
55
    public function test(): bool
56
    {
57
        if ($this->received < $this->min || $this->received > $this->max) {
58
            return true;
59
        }
60
61
        return false;
62
    }
63
}
64