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.

PrimitiveString::_encodedContentDER()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
 * Used by types that don't require special processing of the encoded string data.
16
 *
17
 * @internal
18
 */
19
abstract class PrimitiveString extends BaseString
20
{
21
    use PrimitiveType;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 31
    protected function _encodedContentDER(): string
27
    {
28 31
        return $this->_string;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 67
    protected static function _decodeFromDER(Identifier $identifier,
35
        string $data, int &$offset): ElementBase
36
    {
37 67
        $idx = $offset;
38 67
        if (!$identifier->isPrimitive()) {
39 1
            throw new DecodeException('DER encoded string must be primitive.');
40
        }
41 66
        $length = Length::expectFromDER($data, $idx)->intLength();
42 66
        $str = $length ? substr($data, $idx, $length) : '';
43
        // substr should never return false, since length is
44
        // checked by Length::expectFromDER.
45 66
        assert(is_string($str), new DecodeException('substr'));
46 66
        $offset = $idx + $length;
47
        try {
48 66
            return new static($str);
49 7
        } catch (\InvalidArgumentException $e) {
50 7
            throw new DecodeException($e->getMessage(), 0, $e);
51
        }
52
    }
53
}
54