TokenType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ecodev\Felix\Api\Scalar;
6
7
final class TokenType extends AbstractStringBasedType
8
{
9
    public ?string $description = 'A user token is a lowercase hexadecimal string of 32 characters or 6 digits.';
10
11
    /**
12
     * Validate a token.
13
     */
14 26
    protected function isValid(?string $value): bool
15
    {
16 26
        return is_string($value) && preg_match('/^([\da-z]{32}|\d{6})$/', $value);
17
    }
18
}
19