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.

UnknownExtension   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 15
dl 0
loc 75
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fromRawString() 0 7 1
A _extnValue() 0 3 1
A _valueASN1() 0 6 2
A extensionValue() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\Certificate\Extension;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Type\Primitive\OctetString;
9
10
/**
11
 * Class to park payload of an unknown extension.
12
 */
13
class UnknownExtension extends Extension
14
{
15
    /**
16
     * Decoded extension value.
17
     *
18
     * @var null|Element
19
     */
20
    protected $_element;
21
22
    /**
23
     * Raw extension value.
24
     *
25
     * @var string
26
     */
27
    protected $_data;
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param string  $oid
33
     * @param bool    $critical
34
     * @param Element $element
35
     */
36 7
    public function __construct(string $oid, bool $critical, Element $element)
37
    {
38 7
        parent::__construct($oid, $critical);
39 7
        $this->_element = $element;
40 7
        $this->_data = $element->toDER();
41 7
    }
42
43
    /**
44
     * Create instance from a raw encoded extension value.
45
     *
46
     * @param string $oid
47
     * @param bool   $critical
48
     * @param string $data
49
     *
50
     * @return self
51
     */
52 2
    public static function fromRawString(string $oid, bool $critical,
53
        string $data): self
54
    {
55 2
        $obj = new self($oid, $critical, new OctetString(''));
56 2
        $obj->_element = null;
57 2
        $obj->_data = $data;
58 2
        return $obj;
59
    }
60
61
    /**
62
     * Get the encoded extension value.
63
     *
64
     * @return string
65
     */
66 2
    public function extensionValue(): string
67
    {
68 2
        return $this->_data;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74 2
    protected function _extnValue(): OctetString
75
    {
76 2
        return new OctetString($this->_data);
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82 2
    protected function _valueASN1(): Element
83
    {
84 2
        if (!isset($this->_element)) {
85 1
            throw new \RuntimeException('Extension value is not DER encoded.');
86
        }
87 1
        return $this->_element;
88
    }
89
}
90