ExtensionResponse   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 45.83%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
c 1
b 0
f 1
dl 0
loc 79
ccs 11
cts 24
cp 0.4583
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getIdentifier() 0 3 1
A setAuthenticatorExtensionOutput() 0 4 1
A hasAuthenticatorExtensionOutput() 0 6 2
A setClientExtensionOutput() 0 4 1
A hasClientExtensionOutput() 0 3 1
A getClientExtensionOutput() 0 3 1
A __construct() 0 3 1
A getAuthenticatorExtensionOutput() 0 6 2
1
<?php
2
3
namespace MadWizard\WebAuthn\Extension;
4
5
use MadWizard\WebAuthn\Exception\NotAvailableException;
6
7
final class ExtensionResponse implements ExtensionResponseInterface
8
{
9
    /**
10
     * @var bool
11
     */
12
    private $hasClientExtensionOutput = false;
13
14
    /**
15
     * @var mixed
16
     */
17
    private $clientExtensionOutput;
18
19
    /**
20
     * @var bool
21
     */
22
    private $hasAuthenticatorExtensionOutput = false;
23
24
    /**
25
     * @var mixed
26
     */
27
    private $authenticatorExtensionOutput;
28
29
    /**
30
     * @var string
31
     */
32
    private $identifier;
33
34 3
    public function __construct(string $identifier)
35
    {
36 3
        $this->identifier = $identifier;
37 3
    }
38
39 1
    public function getIdentifier(): string
40
    {
41 1
        return $this->identifier;
42
    }
43
44
    public function hasClientExtensionOutput(): bool
45
    {
46
        return $this->hasClientExtensionOutput;
47
    }
48
49 2
    public function getClientExtensionOutput()
50
    {
51 2
        return $this->clientExtensionOutput;
52
    }
53
54
    public function hasAuthenticatorExtensionOutput(): bool
55
    {
56
        if (!$this->hasClientExtensionOutput) {
57
            throw new NotAvailableException(sprintf('No client extension output is available for extension "%s".', $this->identifier));
58
        }
59
        return $this->hasAuthenticatorExtensionOutput;
60
    }
61
62
    public function getAuthenticatorExtensionOutput()
63
    {
64
        if (!$this->hasAuthenticatorExtensionOutput) {
65
            throw new NotAvailableException(sprintf('No authenticator extension output is available for extension "%s".', $this->identifier));
66
        }
67
        return $this->authenticatorExtensionOutput;
68
    }
69
70
    /**
71
     * @param mixed $clientExtensionOutput
72
     */
73 2
    public function setClientExtensionOutput($clientExtensionOutput): void
74
    {
75 2
        $this->hasClientExtensionOutput = true;
76 2
        $this->clientExtensionOutput = $clientExtensionOutput;
77 2
    }
78
79
    /**
80
     * @param mixed $authenticatorExtensionOutput
81
     */
82
    public function setAuthenticatorExtensionOutput($authenticatorExtensionOutput): void
83
    {
84
        $this->hasAuthenticatorExtensionOutput = true;
85
        $this->authenticatorExtensionOutput = $authenticatorExtensionOutput;
86
    }
87
}
88