Between   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A passes() 0 12 3
A message() 0 4 1
1
<?php
2
3
namespace Infinitypaul\Validator\Rules;
4
5
class Between extends Rule
6
{
7
    /**
8
     * @var int
9
     */
10
    protected $lower;
11
    /**
12
     * @var int
13
     */
14
    protected $upper;
15
16
    /**
17
     * Between constructor.
18
     *
19
     * @param $lower
20
     * @param $upper
21
     */
22
    public function __construct($lower, $upper)
23
    {
24
        $this->lower = $lower;
25
        $this->upper = $upper;
26
    }
27
28
    /**
29
     * @param $field
30
     * @param $value
31
     * @param $data
32
     *
33
     * @return bool
34
     */
35
    public function passes($field, $value, $data): bool
36
    {
37
        if (strlen($value) < (int) $this->lower) {
38
            return false;
39
        }
40
41
        if (strlen($value) > (int) $this->lower) {
42
            return false;
43
        }
44
45
        return true;
46
    }
47
48
    /**
49
     * @param $field
50
     *
51
     * @return string
52
     */
53
    public function message($field): string
54
    {
55
        return $field.' Must Be Between '.$this->lower.' And '.$this->upper.' Characters';
56
    }
57
}
58