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.

Set   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 19
dl 0
loc 49
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A sortedSetOf() 0 10 1
A sortedSet() 0 14 5
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\ASN1\Type\Constructed;
6
7
use Sop\ASN1\Element;
8
use Sop\ASN1\Type\Structure;
9
10
/**
11
 * Implements *SET* and *SET OF* types.
12
 */
13
class Set extends Structure
14
{
15
    /**
16
     * Constructor.
17
     *
18
     * @param Element ...$elements Any number of elements
19
     */
20 12
    public function __construct(Element ...$elements)
21
    {
22 12
        $this->_typeTag = self::TYPE_SET;
23 12
        parent::__construct(...$elements);
24 12
    }
25
26
    /**
27
     * Sort by canonical ascending order.
28
     *
29
     * Used for DER encoding of *SET* type.
30
     */
31 3
    public function sortedSet(): self
32
    {
33 3
        $obj = clone $this;
34 3
        usort($obj->_elements,
35
            function (Element $a, Element $b) {
36 3
                if ($a->typeClass() !== $b->typeClass()) {
37 1
                    return $a->typeClass() < $b->typeClass() ? -1 : 1;
38
                }
39 3
                if ($a->tag() === $b->tag()) {
40 1
                    return 0;
41
                }
42 2
                return $a->tag() < $b->tag() ? -1 : 1;
43 3
            });
44 3
        return $obj;
45
    }
46
47
    /**
48
     * Sort by encoding ascending order.
49
     *
50
     * Used for DER encoding of *SET OF* type.
51
     */
52 1
    public function sortedSetOf(): self
53
    {
54 1
        $obj = clone $this;
55 1
        usort($obj->_elements,
56
            function (Element $a, Element $b) {
57 1
                $a_der = $a->toDER();
58 1
                $b_der = $b->toDER();
59 1
                return strcmp($a_der, $b_der);
60 1
            });
61 1
        return $obj;
62
    }
63
}
64