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
Pull Request — master (#1)
by thomas
05:34
created

SvceAuthInfo   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 155
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 7
dl 0
loc 155
ccs 0
cts 38
cp 0
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A fromASN1() 0 13 2
A service() 0 4 1
A ident() 0 4 1
A hasAuthInfo() 0 4 1
A authInfo() 0 7 2
A toASN1() 0 8 2
A stringValue() 0 4 1
A equalityMatchingRule() 0 4 1
A rfc2253String() 0 4 1
A _transcodedString() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace X509\AttributeCertificate\Attribute;
6
7
use ASN1\Element;
8
use ASN1\Type\UnspecifiedType;
9
use ASN1\Type\Constructed\Sequence;
10
use ASN1\Type\Primitive\OctetString;
11
use X501\ASN1\AttributeValue\AttributeValue;
12
use X501\MatchingRule\BinaryMatch;
13
use X509\GeneralName\GeneralName;
14
15
/**
16
 * Base class implementing <i>SvceAuthInfo</i> ASN.1 type used by
17
 * attribute certificate attribute values.
18
 *
19
 * @link https://tools.ietf.org/html/rfc5755#section-4.4.1
20
 */
21
abstract class SvceAuthInfo extends AttributeValue
22
{
23
    /**
24
     * Service.
25
     *
26
     * @var GeneralName $_service
27
     */
28
    protected $_service;
29
    
30
    /**
31
     * Ident.
32
     *
33
     * @var GeneralName $_ident
34
     */
35
    protected $_ident;
36
    
37
    /**
38
     * Auth info.
39
     *
40
     * @var string|null $_authInfo
41
     */
42
    protected $_authInfo;
43
    
44
    /**
45
     * Constructor.
46
     *
47
     * @param GeneralName $service
48
     * @param GeneralName $ident
49
     * @param string|null $auth_info
50
     */
51
    public function __construct(GeneralName $service, GeneralName $ident,
52
        string $auth_info = null)
53
    {
54
        $this->_service = $service;
55
        $this->_ident = $ident;
56
        $this->_authInfo = $auth_info;
57
    }
58
    
59
    /**
60
     *
61
     * @param UnspecifiedType $el
62
     * @return self
63
     */
64
    public static function fromASN1(UnspecifiedType $el)
65
    {
66
        $seq = $el->asSequence();
67
        $service = GeneralName::fromASN1($seq->at(0)->asTagged());
68
        $ident = GeneralName::fromASN1($seq->at(1)->asTagged());
69
        $auth_info = null;
70
        if ($seq->has(2, Element::TYPE_OCTET_STRING)) {
71
            $auth_info = $seq->at(2)
72
                ->asString()
73
                ->string();
74
        }
75
        return new static($service, $ident, $auth_info);
76
    }
77
    
78
    /**
79
     * Get service name.
80
     *
81
     * @return GeneralName
82
     */
83
    public function service(): GeneralName
84
    {
85
        return $this->_service;
86
    }
87
    
88
    /**
89
     * Get ident.
90
     *
91
     * @return GeneralName
92
     */
93
    public function ident(): GeneralName
94
    {
95
        return $this->_ident;
96
    }
97
    
98
    /**
99
     * Check whether authentication info is present.
100
     *
101
     * @return bool
102
     */
103
    public function hasAuthInfo(): bool
104
    {
105
        return isset($this->_authInfo);
106
    }
107
    
108
    /**
109
     * Get authentication info.
110
     *
111
     * @throws \LogicException
112
     * @return string
113
     */
114
    public function authInfo(): string
115
    {
116
        if (!$this->hasAuthInfo()) {
117
            throw new \LogicException("authInfo not set.");
118
        }
119
        return $this->_authInfo;
120
    }
121
    
122
    /**
123
     *
124
     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
125
     * @return Sequence
126
     */
127
    public function toASN1(): Sequence
128
    {
129
        $elements = array($this->_service->toASN1(), $this->_ident->toASN1());
130
        if (isset($this->_authInfo)) {
131
            $elements[] = new OctetString($this->_authInfo);
132
        }
133
        return new Sequence(...$elements);
134
    }
135
    
136
    /**
137
     *
138
     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
139
     * @return string
140
     */
141
    public function stringValue(): string
142
    {
143
        return "#" . bin2hex($this->toASN1()->toDER());
144
    }
145
    
146
    /**
147
     *
148
     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
149
     * @return BinaryMatch
150
     */
151
    public function equalityMatchingRule(): BinaryMatch
152
    {
153
        return new BinaryMatch();
154
    }
155
    
156
    /**
157
     *
158
     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
159
     * @return string
160
     */
161
    public function rfc2253String(): string
162
    {
163
        return $this->stringValue();
164
    }
165
    
166
    /**
167
     *
168
     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
169
     * @return string
170
     */
171
    protected function _transcodedString(): string
172
    {
173
        return $this->stringValue();
174
    }
175
}
176