BetweenInclusiveRule::getDescription()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 4
nop 0
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 3
rs 10
c 1
b 0
f 0
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 value in range between minimum and maximum values
16
 *
17
 * @package Bluz\Validator\Rule
18
 */
19
class BetweenInclusiveRule extends BetweenRule
20
{
21
    /**
22
     * @var bool
23
     */
24
    protected $inclusive = true;
25
26
    /**
27
     * Get error template
28
     *
29
     * @return string
30
     */
31 8
    public function getDescription(): string
32
    {
33
34 8
        $min = $this->minValue;
35 8
        $max = $this->maxValue;
36
37 8
        if ($min instanceof \DateTime) {
38 2
            $min = date_format($min, 'r');
39
        }
40 8
        if ($max instanceof \DateTime) {
41 2
            $max = date_format($max, 'r');
42
        }
43
44 8
        return __('must be inclusive between "%1s" and "%2s"', $min, $max);
45
    }
46
}
47