GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 2569ae...192447 )
by Joni
08:37
created

AuthorityInformationAccessExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 5
dl 0
loc 84
ccs 22
cts 22
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A _fromDER() 0 8 1
A accessDescriptions() 0 4 1
A _valueASN1() 0 8 1
A count() 0 4 1
A getIterator() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace X509\Certificate\Extension;
5
6
use ASN1\Type\UnspecifiedType;
7
use ASN1\Type\Constructed\Sequence;
8
use X509\Certificate\Extension\AccessDescription\AccessDescription;
9
use X509\Certificate\Extension\AccessDescription\AuthorityAccessDescription;
10
11
/**
12
 * Implements 'Authority Information Access' extension.
13
 *
14
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.2.1
15
 */
16
class AuthorityInformationAccessExtension extends Extension implements 
17
    \Countable,
18
    \IteratorAggregate
19
{
20
    /**
21
     * Access descriptions.
22
     *
23
     * @var AuthorityAccessDescription[]
24
     */
25
    private $_accessDescriptions;
26
    
27
    /**
28
     * Constructor.
29
     *
30
     * @param bool $critical
31
     * @param AuthorityAccessDescription ...$access
32
     */
33 10
    public function __construct(bool $critical,
34
        AuthorityAccessDescription ...$access)
35
    {
36 10
        parent::__construct(self::OID_AUTHORITY_INFORMATION_ACCESS, $critical);
37 10
        $this->_accessDescriptions = $access;
38 10
    }
39
    
40
    /**
41
     *
42
     * {@inheritdoc}
43
     * @return self
44
     */
45 9
    protected static function _fromDER(string $data, bool $critical): self
46
    {
47 9
        $access = array_map(
48 9
            function (UnspecifiedType $el) {
49 9
                return AuthorityAccessDescription::fromASN1($el->asSequence());
50 9
            }, UnspecifiedType::fromDER($data)->asSequence()->elements());
51 9
        return new self($critical, ...$access);
52
    }
53
    
54
    /**
55
     * Get the access descriptions.
56
     *
57
     * @return AuthorityAccessDescription[]
58
     */
59 1
    public function accessDescriptions(): array
60
    {
61 1
        return $this->_accessDescriptions;
62
    }
63
    
64
    /**
65
     *
66
     * {@inheritdoc}
67
     * @return Sequence
68
     */
69 15
    protected function _valueASN1(): Sequence
70
    {
71 15
        $elements = array_map(
72 15
            function (AccessDescription $access) {
73 15
                return $access->toASN1();
74 15
            }, $this->_accessDescriptions);
75 15
        return new Sequence(...$elements);
76
    }
77
    
78
    /**
79
     * Get the number of access descriptions.
80
     *
81
     * @see \Countable::count()
82
     * @return int
83
     */
84 1
    public function count(): int
85
    {
86 1
        return count($this->_accessDescriptions);
87
    }
88
    
89
    /**
90
     * Get iterator for access descriptions.
91
     *
92
     * @see \IteratorAggregate::getIterator()
93
     * @return \ArrayIterator List of AuthorityAccessDescription objects
94
     */
95 1
    public function getIterator(): \ArrayIterator
96
    {
97 1
        return new \ArrayIterator($this->_accessDescriptions);
98
    }
99
}
100