Passed
Push — master ( 3569aa...ab7ae0 )
by Florent
02:27
created

AttestationStatement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace U2FAuthentication\Fido2\AttestationStatement;
15
16
class AttestationStatement
17
{
18
    /**
19
     * @var
20
     */
21
    private $fmt;
22
23
    /**
24
     * @var array
25
     */
26
    private $attStmt;
27
28
    public function __construct($fmt, array $attStmt)
29
    {
30
        $this->fmt = $fmt;
31
        $this->attStmt = $attStmt;
32
    }
33
34
    public function getFmt()
35
    {
36
        return $this->fmt;
37
    }
38
39
    public function getAttStmt(): array
40
    {
41
        return $this->attStmt;
42
    }
43
44
    public function has(string $key): bool
45
    {
46
        return array_key_exists($key, $this->attStmt);
47
    }
48
49
    public function get(string $key)
50
    {
51
        if (!$this->has($key)) {
52
            throw new \InvalidArgumentException(sprintf('The attestation statement has no key "%s".', $key));
53
        }
54
55
        return $this->attStmt[$key];
56
    }
57
}
58