BetweenRule::run()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 3
nc 5
nop 3
dl 0
loc 6
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
4
namespace SolBianca\Validator\Rules;
5
6
7
use SolBianca\Validator\Interfaces\RuleInterface;
8
9
class BetweenRule implements RuleInterface
10
{
11
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function run($value, array $input, array $args): bool
16
    {
17
        if (!is_numeric($value)) {
18
            return false;
19
        }
20
        return ($value >= $args[0] && $value <= $args[1]) ? true : false;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function errorMessage(): string
27
    {
28
        return 'Field `{field}` must be between `{$0}` and `{$1}``.';
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function canSkip(): bool
35
    {
36
        return true;
37
    }
38
}