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

SubjectInformationAccessExtension::_valueASN1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
crap 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\SubjectAccessDescription;
10
11
/**
12
 * Implements 'Subject Information Access' extension.
13
 *
14
 * @link https://tools.ietf.org/html/rfc5280#section-4.2.2.2
15
 */
16
class SubjectInformationAccessExtension extends Extension implements 
17
    \Countable,
18
    \IteratorAggregate
19
{
20
    /**
21
     * Access descriptions.
22
     *
23
     * @var SubjectAccessDescription[]
24
     */
25
    private $_accessDescriptions;
26
    
27
    /**
28
     * Constructor.
29
     *
30
     * @param bool $critical
31
     * @param SubjectAccessDescription ...$access
32
     */
33 2
    public function __construct(bool $critical,
34
        SubjectAccessDescription ...$access)
35
    {
36 2
        parent::__construct(self::OID_SUBJECT_INFORMATION_ACCESS, $critical);
37 2
        $this->_accessDescriptions = $access;
38 2
    }
39
    
40
    /**
41
     *
42
     * {@inheritdoc}
43
     * @return self
44
     */
45 1
    protected static function _fromDER(string $data, bool $critical): self
46
    {
47 1
        $access = array_map(
48 1
            function (UnspecifiedType $el) {
49 1
                return SubjectAccessDescription::fromASN1($el->asSequence());
50 1
            }, UnspecifiedType::fromDER($data)->asSequence()->elements());
51 1
        return new self($critical, ...$access);
52
    }
53
    
54
    /**
55
     * Get the access descriptions.
56
     *
57
     * @return SubjectAccessDescription[]
58
     */
59 1
    public function accessDescriptions(): array
60
    {
61 1
        return $this->_accessDescriptions;
62
    }
63
    
64
    /**
65
     *
66
     * {@inheritdoc}
67
     * @return Sequence
68
     */
69 1
    protected function _valueASN1(): Sequence
70
    {
71 1
        $elements = array_map(
72 1
            function (AccessDescription $access) {
73 1
                return $access->toASN1();
74 1
            }, $this->_accessDescriptions);
75 1
        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 SubjectAccessDescription objects
94
     */
95 1
    public function getIterator(): \ArrayIterator
96
    {
97 1
        return new \ArrayIterator($this->_accessDescriptions);
98
    }
99
}
100