Digits::getMessage()   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
declare(strict_types = 1);
4
5
namespace Hop\Validator\Validator;
6
7
class Digits implements RuleValidator
8
{
9
    use IsValidTrait;
10
11
    /**
12
     * @inheritdoc
13
     */
14 2
    public function getMessage($value, ?array $options)
15
    {
16 2
        if (!preg_match('/^\d+$/', (string)$value)) {
17 1
            return 'Value is not a number';
18
        }
19 1
        return null;
20
    }
21
}
22