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 ( 95c197...564e5e )
by Joni
04:32
created

PrimitiveString   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 32
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _decodeFromDER() 0 17 4
A _encodedContentDER() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\ASN1\Type;
6
7
use Sop\ASN1\Component\Identifier;
8
use Sop\ASN1\Component\Length;
9
use Sop\ASN1\Exception\DecodeException;
10
use Sop\ASN1\Feature\ElementBase;
11
12
/**
13
 * Base class for primitive strings.
14
 */
15
abstract class PrimitiveString extends StringType
16
{
17
    use PrimitiveType;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 17
    protected function _encodedContentDER(): string
23
    {
24 17
        return $this->_string;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 53
    protected static function _decodeFromDER(Identifier $identifier,
31
        string $data, int &$offset): ElementBase
32
    {
33 53
        $idx = $offset;
34 53
        if (!$identifier->isPrimitive()) {
35 1
            throw new DecodeException('DER encoded string must be primitive.');
36
        }
37 52
        $length = Length::expectFromDER($data, $idx)->intLength();
38 51
        $str = $length ? substr($data, $idx, $length) : '';
39
        // substr should never return false, since length is
40
        // checked by Length::expectFromDER.
41 51
        assert(is_string($str), new DecodeException('substr'));
42 51
        $offset = $idx + $length;
43
        try {
44 51
            return new static($str);
45 6
        } catch (\InvalidArgumentException $e) {
46 6
            throw new DecodeException($e->getMessage(), 0, $e);
47
        }
48
    }
49
}
50