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.
Test Failed
Push — master ( 405cf3...79c9ba )
by Joni
04:48
created

UserNoticeQualifier::explicitText()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\Certificate\Extension\CertificatePolicy;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Type\Constructed\Sequence;
9
use Sop\ASN1\Type\UnspecifiedType;
10
11
/**
12
 * Implements *UserNotice* 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 UserNoticeQualifier extends PolicyQualifierInfo
18
{
19
    /**
20
     * Explicit notice text.
21
     *
22
     * @var null|DisplayText
23
     */
24
    protected $_text;
25
26
    /**
27
     * Notice reference.
28
     *
29
     * @var null|NoticeReference
30
     */
31
    protected $_ref;
32
33
    /**
34
     * Constructor.
35
     *
36
     * @param null|DisplayText     $text
37
     * @param null|NoticeReference $ref
38
     */
39 16
    public function __construct(?DisplayText $text = null,
40
        ?NoticeReference $ref = null)
41 16
    {
42 16
        $this->_oid = self::OID_UNOTICE;
43 16
        $this->_text = $text;
44 16
        $this->_ref = $ref;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     *
50
     * @return self
51 11
     */
52
    public static function fromQualifierASN1(UnspecifiedType $el): PolicyQualifierInfo
53 11
    {
54 11
        $seq = $el->asSequence();
55 11
        $ref = null;
56 11
        $text = null;
57 11
        $idx = 0;
58 10
        if ($seq->has($idx, Element::TYPE_SEQUENCE)) {
59
            $ref = NoticeReference::fromASN1($seq->at($idx++)->asSequence());
60 11
        }
61 11
        if ($seq->has($idx, Element::TYPE_STRING)) {
62
            $text = DisplayText::fromASN1($seq->at($idx)->asString());
63 11
        }
64
        return new self($text, $ref);
65
    }
66
67
    /**
68
     * Whether explicit text is present.
69
     *
70
     * @return bool
71 5
     */
72
    public function hasExplicitText(): bool
73 5
    {
74
        return isset($this->_text);
75
    }
76
77
    /**
78
     * Get explicit text.
79
     *
80
     * @throws \LogicException If not set
81 5
     *
82
     * @return DisplayText
83 5
     */
84 1
    public function explicitText(): DisplayText
85
    {
86 4
        if (!$this->hasExplicitText()) {
87
            throw new \LogicException('explicitText not set.');
88
        }
89
        return $this->_text;
90
    }
91
92
    /**
93
     * Whether notice reference is present.
94 4
     *
95
     * @return bool
96 4
     */
97
    public function hasNoticeRef(): bool
98
    {
99
        return isset($this->_ref);
100
    }
101
102
    /**
103
     * Get notice reference.
104
     *
105 4
     * @throws \LogicException If not set
106
     *
107 4
     * @return NoticeReference
108 1
     */
109
    public function noticeRef(): NoticeReference
110 3
    {
111
        if (!$this->hasNoticeRef()) {
112
            throw new \LogicException('noticeRef not set.');
113
        }
114
        return $this->_ref;
115
    }
116
117
    /**
118 18
     * {@inheritdoc}
119
     */
120 18
    protected function _qualifierASN1(): Element
121 18
    {
122 16
        $elements = [];
123
        if (isset($this->_ref)) {
124 18
            $elements[] = $this->_ref->toASN1();
125 18
        }
126
        if (isset($this->_text)) {
127 18
            $elements[] = $this->_text->toASN1();
128
        }
129
        return new Sequence(...$elements);
130
    }
131
}
132