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.
Completed
Push — master ( 0b237d...cd265f )
by Joni
06:43 queued 17s
created

Attributes   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 11
dl 0
loc 48
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A extensionRequest() 0 6 2
A _castAttributeValues() 0 7 2
A hasExtensionRequest() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\CertificationRequest;
6
7
use Sop\X501\ASN1\Attribute;
8
use Sop\X501\ASN1\Collection\SetOfAttributes;
9
use Sop\X509\CertificationRequest\Attribute\ExtensionRequestValue;
10
11
/**
12
 * Implements *Attributes* ASN.1 type of *CertificationRequestInfo*.
13
 *
14
 * @see https://tools.ietf.org/html/rfc2986#section-4
15
 */
16
class Attributes extends SetOfAttributes
17
{
18
    /**
19
     * Mapping from OID to attribute value class name.
20
     *
21
     * @internal
22
     *
23
     * @var array
24
     */
25
    const MAP_OID_TO_CLASS = [
26
        ExtensionRequestValue::OID => ExtensionRequestValue::class,
27
    ];
28
29
    /**
30
     * Check whether extension request attribute is present.
31
     *
32
     * @return bool
33
     */
34 6
    public function hasExtensionRequest(): bool
35
    {
36 6
        return $this->has(ExtensionRequestValue::OID);
37
    }
38
39
    /**
40
     * Get extension request attribute value.
41
     *
42
     * @throws \LogicException
43
     *
44
     * @return ExtensionRequestValue
45
     */
46 4
    public function extensionRequest(): ExtensionRequestValue
47
    {
48 4
        if (!$this->hasExtensionRequest()) {
49 1
            throw new \LogicException('No extension request attribute.');
50
        }
51 3
        return $this->firstOf(ExtensionRequestValue::OID)->first();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 4
    protected static function _castAttributeValues(Attribute $attribute): Attribute
58
    {
59 4
        $oid = $attribute->oid();
60 4
        if (isset(self::MAP_OID_TO_CLASS[$oid])) {
61 4
            return $attribute->castValues(self::MAP_OID_TO_CLASS[$oid]);
62
        }
63 1
        return $attribute;
64
    }
65
}
66