RegistrationContext::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 4
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace MadWizard\WebAuthn\Server\Registration;
4
5
use MadWizard\WebAuthn\Credential\UserHandle;
6
use MadWizard\WebAuthn\Format\ByteBuffer;
7
use MadWizard\WebAuthn\Server\AbstractContext;
8
use MadWizard\WebAuthn\Web\Origin;
9
use Serializable;
10
11
final class RegistrationContext extends AbstractContext implements Serializable
12
{
13
    /**
14
     * @var UserHandle
15
     */
16
    private $userHandle;
17
18 2
    public function __construct(ByteBuffer $challenge, Origin $origin, string $rpId, UserHandle $userHandle)
19
    {
20 2
        parent::__construct($challenge, $origin, $rpId);
21 2
        $this->userHandle = $userHandle;
22 2
    }
23
24 1
    public function getUserHandle(): UserHandle
25
    {
26 1
        return $this->userHandle;
27
    }
28
29
    public function __serialize(): array
30
    {
31
        return [
32
            'parent' => parent::__serialize(),
33
            'userHandle' => $this->userHandle,
34
        ];
35
    }
36
37
    public function __unserialize(array $data): void
38
    {
39
        parent::__unserialize($data['parent']);
40
        $this->userHandle = $data['userHandle'];
41
    }
42
}
43