NumberRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 3 1
A errorMessage() 0 3 1
A canSkip() 0 3 1
1
<?php
2
3
4
namespace SolBianca\Validator\Rules;
5
6
7
use SolBianca\Validator\Interfaces\RuleInterface;
8
9
class NumberRule implements RuleInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function run($value, array $input, array $args): bool
15
    {
16
        return is_numeric($value);
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function errorMessage(): string
23
    {
24
        return 'Field `{field}` must be a number.';
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function canSkip(): bool
31
    {
32
        return true;
33
    }
34
}