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.

NoticeReference   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 19
dl 0
loc 78
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A organization() 0 3 1
A toASN1() 0 8 1
A fromASN1() 0 8 1
A numbers() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\Certificate\Extension\CertificatePolicy;
6
7
use Sop\ASN1\Type\Constructed\Sequence;
8
use Sop\ASN1\Type\Primitive\Integer;
9
use Sop\ASN1\Type\UnspecifiedType;
10
11
/**
12
 * Implements *NoticeReference* ASN.1 type used by 'Certificate Policies'
13
 * certificate extension.
14
 *
15
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.4
16
 */
17
class NoticeReference
18
{
19
    /**
20
     * Organization.
21
     *
22
     * @var DisplayText
23
     */
24
    protected $_organization;
25
26
    /**
27
     * Notification reference numbers.
28
     *
29
     * @var int[]
30
     */
31
    protected $_numbers;
32
33
    /**
34
     * Constructor.
35
     *
36
     * @param DisplayText $organization
37
     * @param int         ...$numbers
38
     */
39 14
    public function __construct(DisplayText $organization, int ...$numbers)
40
    {
41 14
        $this->_organization = $organization;
42 14
        $this->_numbers = $numbers;
43 14
    }
44
45
    /**
46
     * Initialize from ASN.1.
47
     *
48
     * @param Sequence $seq
49
     *
50
     * @return self
51
     */
52 11
    public static function fromASN1(Sequence $seq): self
53
    {
54 11
        $org = DisplayText::fromASN1($seq->at(0)->asString());
55 11
        $numbers = array_map(
56
            function (UnspecifiedType $el) {
57 11
                return $el->asInteger()->intNumber();
58 11
            }, $seq->at(1)->asSequence()->elements());
59 11
        return new self($org, ...$numbers);
60
    }
61
62
    /**
63
     * Get reference organization.
64
     *
65
     * @return DisplayText
66
     */
67 3
    public function organization(): DisplayText
68
    {
69 3
        return $this->_organization;
70
    }
71
72
    /**
73
     * Get reference numbers.
74
     *
75
     * @return int[]
76
     */
77 3
    public function numbers(): array
78
    {
79 3
        return $this->_numbers;
80
    }
81
82
    /**
83
     * Generate ASN.1 structure.
84
     *
85
     * @return Sequence
86
     */
87 17
    public function toASN1(): Sequence
88
    {
89 17
        $org = $this->_organization->toASN1();
90 17
        $nums = array_map(
91
            function ($number) {
92 17
                return new Integer($number);
93 17
            }, $this->_numbers);
94 17
        return new Sequence($org, new Sequence(...$nums));
95
    }
96
}
97