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.

PolicyQualifierInfo::oid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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\Primitive\ObjectIdentifier;
10
use Sop\ASN1\Type\UnspecifiedType;
11
12
/**
13
 * Base class for *PolicyQualifierInfo* ASN.1 types used by 'Certificate Policies'
14
 * certificate extension.
15
 *
16
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.4
17
 */
18
abstract class PolicyQualifierInfo
19
{
20
    /**
21
     * OID for the CPS Pointer qualifier.
22
     *
23
     * @var string
24
     */
25
    const OID_CPS = '1.3.6.1.5.5.7.2.1';
26
27
    /**
28
     * OID for the user notice qualifier.
29
     *
30
     * @var string
31
     */
32
    const OID_UNOTICE = '1.3.6.1.5.5.7.2.2';
33
34
    /**
35
     * Qualifier identifier.
36
     *
37
     * @var string
38
     */
39
    protected $_oid;
40
41
    /**
42
     * Initialize from qualifier ASN.1 element.
43
     *
44
     * @param UnspecifiedType $el
45
     *
46
     * @return self
47
     */
48 1
    public static function fromQualifierASN1(UnspecifiedType $el): PolicyQualifierInfo
49
    {
50 1
        throw new \BadMethodCallException(
51 1
            __FUNCTION__ . ' must be implemented in the derived class.');
52
    }
53
54
    /**
55
     * Initialize from ASN.1.
56
     *
57
     * @param Sequence $seq
58
     *
59
     * @throws \UnexpectedValueException
60
     *
61
     * @return self
62
     */
63 14
    public static function fromASN1(Sequence $seq): self
64
    {
65 14
        $oid = $seq->at(0)->asObjectIdentifier()->oid();
66
        switch ($oid) {
67 14
            case self::OID_CPS:
68 12
                return CPSQualifier::fromQualifierASN1($seq->at(1));
69 12
            case self::OID_UNOTICE:
70 11
                return UserNoticeQualifier::fromQualifierASN1($seq->at(1));
71
        }
72 1
        throw new \UnexpectedValueException("Qualifier {$oid} not supported.");
73
    }
74
75
    /**
76
     * Get qualifier identifier.
77
     *
78
     * @return string
79
     */
80 17
    public function oid(): string
81
    {
82 17
        return $this->_oid;
83
    }
84
85
    /**
86
     * Generate ASN.1 structure.
87
     *
88
     * @return Sequence
89
     */
90 20
    public function toASN1(): Sequence
91
    {
92 20
        return new Sequence(new ObjectIdentifier($this->_oid),
93 20
            $this->_qualifierASN1());
94
    }
95
96
    /**
97
     * Generate ASN.1 for the 'qualifier' field.
98
     *
99
     * @return Element
100
     */
101
    abstract protected function _qualifierASN1(): Element;
102
}
103