Passed
Push — master ( a019b6...0010e9 )
by Thomas
08:57
created

AbstractExtension::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace MadWizard\WebAuthn\Extension;
4
5
use MadWizard\WebAuthn\Exception\WebAuthnException;
6
7
abstract class AbstractExtension implements ExtensionInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $identifier;
13
14 5
    public function __construct(string $identifier)
15
    {
16 5
        $this->identifier = $identifier;
17
18 5
        if (!ExtensionHelper::validExtensionIdentifier($identifier)) {
19
            throw new WebAuthnException(sprintf("Invalid extension identifier '%s'.", $identifier));
20
        }
21 5
    }
22
23
    public function getIdentifier(): string
24
    {
25
        return $this->identifier;
26
    }
27
}
28