AbstractCompareRule::less()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
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
 * Abstract rule of compare
16
 *
17
 * @package Bluz\Validator\Rule
18
 */
19
abstract class AbstractCompareRule extends AbstractRule
20
{
21
    /**
22
     * @var bool compare inclusive or not
23
     */
24
    protected $inclusive;
25
26
    /**
27
     * Check $what less $than or not
28
     *
29
     * @param  mixed $what
30
     * @param  mixed $than
31
     *
32
     * @return bool
33
     */
34 69
    protected function less($what, $than): bool
35
    {
36 69
        if ($this->inclusive) {
37 40
            return $what <= $than;
38
        }
39 29
        return $what < $than;
40
    }
41
}
42