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.
Passed
Push — master ( 035734...405cf3 )
by Joni
28:16
created

UnknownExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 78
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

5 Methods

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