CredentialId   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
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 25
ccs 10
cts 10
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A equals() 0 3 1
A fromBuffer() 0 3 1
A fromHex() 0 3 1
A fromString() 0 3 1
A fromBinary() 0 3 1
1
<?php
2
3
namespace MadWizard\WebAuthn\Credential;
4
5
use MadWizard\WebAuthn\Format\Base64UrlEncoding;
6
use MadWizard\WebAuthn\Format\BinaryHandle;
7
use MadWizard\WebAuthn\Format\ByteBuffer;
8
use function hash_equals;
9
10
class CredentialId extends BinaryHandle
11
{
12 17
    public static function fromString(string $base64urlString): self
13
    {
14 17
        return new self(Base64UrlEncoding::decode($base64urlString));
15
    }
16
17 11
    public static function fromBinary(string $binary): self
18
    {
19 11
        return new self($binary);
20
    }
21
22 3
    public static function fromHex(string $hex): self
23
    {
24 3
        return new self(parent::convertHex($hex));
25
    }
26
27 14
    public static function fromBuffer(ByteBuffer $buffer): self
28
    {
29 14
        return new self($buffer->getBinaryString());
30
    }
31
32 12
    public function equals(self $other): bool
33
    {
34 12
        return hash_equals($this->raw, $other->raw);
35
    }
36
}
37