Failed Conditions
Push — master ( 12e8b5...0c68f2 )
by Sylvain
18s queued 15s
created

OtpType::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Api\Scalar;
6
7
class OtpType extends AbstractStringBasedType
8
{
9
    /**
10
     * @var string
11
     */
12
    public $description = 'One time passcode composed of only digits';
13
14
    /**
15
     * Validate an OTP.
16
     */
17 12
    protected function isValid(?string $value): bool
18
    {
19 12
        return is_string($value) && preg_match('/^\d{6}+$/', $value);
20
    }
21
}
22