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.

AuthorityInformationAccessExtension::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\Certificate\Extension;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Type\Constructed\Sequence;
9
use Sop\ASN1\Type\UnspecifiedType;
10
use Sop\X509\Certificate\Extension\AccessDescription\AccessDescription;
11
use Sop\X509\Certificate\Extension\AccessDescription\AuthorityAccessDescription;
12
13
/**
14
 * Implements 'Authority Information Access' extension.
15
 *
16
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.2.1
17
 */
18
class AuthorityInformationAccessExtension extends Extension implements \Countable, \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, AuthorityAccessDescription ...$access)
34
    {
35 10
        parent::__construct(self::OID_AUTHORITY_INFORMATION_ACCESS, $critical);
36 10
        $this->_accessDescriptions = $access;
37 10
    }
38
39
    /**
40
     * Get the access descriptions.
41
     *
42
     * @return AuthorityAccessDescription[]
43
     */
44 1
    public function accessDescriptions(): array
45
    {
46 1
        return $this->_accessDescriptions;
47
    }
48
49
    /**
50
     * Get the number of access descriptions.
51
     *
52
     * @see \Countable::count()
53
     *
54
     * @return int
55
     */
56 1
    public function count(): int
57
    {
58 1
        return count($this->_accessDescriptions);
59
    }
60
61
    /**
62
     * Get iterator for access descriptions.
63
     *
64
     * @see \IteratorAggregate::getIterator()
65
     *
66
     * @return \ArrayIterator List of AuthorityAccessDescription objects
67
     */
68 1
    public function getIterator(): \ArrayIterator
69
    {
70 1
        return new \ArrayIterator($this->_accessDescriptions);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76 9
    protected static function _fromDER(string $data, bool $critical): Extension
77
    {
78 9
        $access = array_map(
79
            function (UnspecifiedType $el) {
80 9
                return AuthorityAccessDescription::fromASN1($el->asSequence());
81 9
            }, UnspecifiedType::fromDER($data)->asSequence()->elements());
82 9
        return new self($critical, ...$access);
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 15
    protected function _valueASN1(): Element
89
    {
90 15
        $elements = array_map(
91
            function (AccessDescription $access) {
92 15
                return $access->toASN1();
93 15
            }, $this->_accessDescriptions);
94 15
        return new Sequence(...$elements);
95
    }
96
}
97