Failed Conditions
Push — master ( 4252f4...9d8e13 )
by Adrien
07:13
created

TokenType::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 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Scalar;
6
7
class TokenType extends AbstractStringBasedType
8
{
9
    /**
10
     * @var string
11
     */
12
    public $description = 'A user token is an lowercase hexadecimal string of 32 characters.';
13
14
    /**
15
     * Validate a token
16
     *
17
     * @param mixed $value
18
     *
19
     * @return bool
20
     */
21 2
    protected function isValid($value): bool
22
    {
23 2
        return is_string($value) && preg_match('/^[\da-z]{32}$/', $value);
24
    }
25
}
26