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 — php72 ( f5fc00...61c5d1 )
by Joni
02:05
created

ConstructedString   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 5 1
A strings() 0 5 1
A _decodeFromDER() 0 8 1
A concatenated() 0 3 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\ASN1\Type\Constructed;
6
7
use Sop\ASN1\Component\Identifier;
8
use Sop\ASN1\Element;
9
use Sop\ASN1\Feature\ElementBase;
10
use Sop\ASN1\Type\PrimitiveString;
11
use Sop\ASN1\Type\Structure;
12
13
/**
14
 * Implements constructed type of simple strings.
15
 */
16
class ConstructedString extends Structure
17
{
18
    /**
19
     * Constructor.
20
     *
21
     * @param Element ...$elements Any number of elements
22
     */
23 7
    protected function __construct(Element ...$elements)
24
    {
25 7
        parent::__construct(...$elements);
26 7
    }
27
28
    /**
29
     * Create constructed string.
30
     *
31
     * @param int             $tag         Type tag
32
     * @param PrimitiveString ...$elements Any number of elements
33
     */
34 3
    public static function create(int $tag, PrimitiveString ...$elements)
35
    {
36 3
        $el = new self(...$elements);
37 3
        $el->_typeTag = $tag;
38 3
        return $el;
39
    }
40
41
    /**
42
     * Get a list of strings in this structure.
43
     *
44
     * @return string[]
45
     */
46 2
    public function strings(): array
47
    {
48
        return array_map(function (PrimitiveString $el) {
49 2
            return $el->string();
50 2
        }, $this->_elements);
51
    }
52
53
    /**
54
     * Get the contained strings concatenated together.
55
     *
56
     * @return string
57
     */
58 1
    public function concatenated(): string
59
    {
60 1
        return implode('', $this->strings());
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     *
66
     * @return self
67
     */
68 4
    protected static function _decodeFromDER(Identifier $identifier,
69
        string $data, int &$offset): ElementBase
70
    {
71
        /** @var ConstructedString $type */
72 4
        $type = forward_static_call_array([parent::class, __FUNCTION__],
73 4
            [$identifier, $data, &$offset]);
74 4
        $type->_typeTag = $identifier->intTag();
75 4
        return $type;
76
    }
77
}
78