CredentialId::fromBuffer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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