Completed
Push — master ( 38deb0...7544ac )
by Anton
11s
created

LessRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

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