Aaid::equals()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

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 0
cts 2
cp 0
crap 6
rs 10
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