Aaid   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 31
ccs 0
cts 12
cp 0
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A equals() 0 3 2
A toString() 0 3 1
A getType() 0 3 1
1
<?php
2
3
namespace MadWizard\WebAuthn\Attestation\Identifier;
4
5
use MadWizard\WebAuthn\Exception\ParseException;
6
7
final class Aaid implements IdentifierInterface
8
{
9
    public const TYPE = 'aaid';
10
11
    /**
12
     * @var string
13
     */
14
    private $aaid;
15
16
    public function __construct(string $aaid)
17
    {
18
        $aaid = strtolower($aaid);
19
        if (!preg_match('~^[0-9A-Fa-f]{4}#[0-9A-Fa-f]{4}$~', $aaid)) {
20
            throw new ParseException('Invalid AAID');
21
        }
22
        $this->aaid = $aaid;
23
    }
24
25
    public function getType(): string
26
    {
27
        return self::TYPE;
28
    }
29
30
    public function toString(): string
31
    {
32
        return $this->aaid;
33
    }
34
35
    public function equals(IdentifierInterface $identifier): bool
36
    {
37
        return $identifier instanceof self && $this->aaid === $identifier->aaid;
38
    }
39
}
40