ExtensionHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validExtensionIdentifier() 0 10 2
1
<?php
2
3
namespace MadWizard\WebAuthn\Extension;
4
5
final class ExtensionHelper
6
{
7
    public const MAX_IDENTIFIER_LENGHT = 32;
8
9 15
    public static function validExtensionIdentifier(string $identifier): bool
10
    {
11
        // SPEC 9.1
12
        // All extension identifiers MUST be a maximum of 32 octets in length and MUST consist only of printable
13
        // USASCII characters, excluding backslash and doublequote, i.e., VCHAR as defined in [RFC5234] but without
14
        // %x22 and %x5c. Implementations MUST match WebAuthn extension identifiers in a case-sensitive fashion.
15 15
        if (strlen($identifier) > self::MAX_IDENTIFIER_LENGHT) {
16 1
            return false;
17
        }
18 15
        return (bool) preg_match('~^[\x21\x23-\x5B\x5D-\x7E]+$~', $identifier);
19
    }
20
}
21