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

TokenType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 17
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 3 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