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

Between   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A test() 0 7 3
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