TokenType::isValid()   A
last analyzed

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
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
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