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

AttestationStatement   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFmt() 0 3 1
A has() 0 3 1
A get() 0 7 2
A getAttStmt() 0 3 1
A __construct() 0 4 1
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