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.

DistributionPointName   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 17
dl 0
loc 63
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tag() 0 3 1
A fromTaggedType() 0 13 3
A toASN1() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\Certificate\Extension\DistributionPoint;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Type\Tagged\ImplicitlyTaggedType;
9
use Sop\ASN1\Type\TaggedType;
10
use Sop\X501\ASN1\RDN;
11
use Sop\X509\GeneralName\GeneralNames;
12
13
/**
14
 * Base class for *DistributionPointName* ASN.1 CHOICE type used by
15
 * 'CRL Distribution Points' certificate extension.
16
 *
17
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.13
18
 */
19
abstract class DistributionPointName
20
{
21
    const TAG_FULL_NAME = 0;
22
    const TAG_RDN = 1;
23
24
    /**
25
     * Type.
26
     *
27
     * @var int
28
     */
29
    protected $_tag;
30
31
    /**
32
     * Initialize from TaggedType.
33
     *
34
     * @param TaggedType $el
35
     *
36
     * @throws \UnexpectedValueException
37
     *
38
     * @return self
39
     */
40 15
    public static function fromTaggedType(TaggedType $el): self
41
    {
42 15
        switch ($el->tag()) {
43 15
            case self::TAG_FULL_NAME:
44 12
                return new FullName(
45 12
                    GeneralNames::fromASN1(
46 12
                        $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence()));
47 11
            case self::TAG_RDN:
48 10
                return new RelativeName(
49 10
                    RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet()));
50
            default:
51 1
                throw new \UnexpectedValueException(
52 1
                    'DistributionPointName tag ' . $el->tag() . ' not supported.');
53
        }
54
    }
55
56
    /**
57
     * Get type tag.
58
     *
59
     * @return int
60
     */
61 7
    public function tag(): int
62
    {
63 7
        return $this->_tag;
64
    }
65
66
    /**
67
     * Generate ASN.1 structure.
68
     *
69
     * @return ImplicitlyTaggedType
70
     */
71 20
    public function toASN1(): ImplicitlyTaggedType
72
    {
73 20
        return new ImplicitlyTaggedType($this->_tag, $this->_valueASN1());
74
    }
75
76
    /**
77
     * Generate ASN.1 element.
78
     *
79
     * @return Element
80
     */
81
    abstract protected function _valueASN1(): Element;
82
}
83