Max::message()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Infinitypaul\Validator\Rules;
4
5
class Max extends Rule
6
{
7
    /**
8
     * @var int
9
     */
10
    protected $max;
11
12
    /**
13
     * Max constructor.
14
     *
15
     * @param $max
16
     */
17
    public function __construct($max)
18
    {
19
        $this->max = $max;
20
    }
21
22
    /**
23
     * @param $field
24
     * @param $value
25
     *
26
     * @param $data
27
     *
28
     * @return bool
29
     */
30
    public function passes($field, $value, $data): bool
31
    {
32
        return strlen($value) <= $this->max;
33
    }
34
35
    /**
36
     * @param $field
37
     *
38
     * @return string
39
     */
40
    public function message($field): string
41
    {
42
        return $field.' Must Be A Max Of '.$this->max.' Characters';
43
    }
44
}
45