LessRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 37
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getDescription() 0 3 1
A validate() 0 3 1
1
<?php
2
3
/**
4
 * Bluz Framework Component
5
 *
6
 * @copyright Bluz PHP Team
7
 * @link      https://github.com/bluzphp/framework
8
 */
9
10
declare(strict_types=1);
11
12
namespace Bluz\Validator\Rule;
13
14
/**
15
 * Check for maximum
16
 *
17
 * @package Bluz\Validator\Rule
18
 */
19
class LessRule extends AbstractCompareRule
20
{
21
    /**
22
     * @var mixed maximum value
23
     */
24
    protected $maxValue;
25
26
    /**
27
     * Setup validation rule
28
     *
29
     * @param mixed $maxValue
30
     */
31 16
    public function __construct($maxValue)
32
    {
33 16
        $this->maxValue = $maxValue;
34 16
    }
35
36
    /**
37
     * Check input data
38
     *
39
     * @param  NumericRule $input
40
     *
41
     * @return bool
42
     */
43 16
    public function validate($input): bool
44
    {
45 16
        return $this->less($input, $this->maxValue);
46
    }
47
48
    /**
49
     * Get error template
50
     *
51
     * @return string
52
     */
53 7
    public function getDescription(): string
54
    {
55 7
        return __('must be lower than "%s"', $this->maxValue);
56
    }
57
}
58