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
Branch php72 (57c34e)
by Joni
05:01
created

Boolean   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 5
dl 0
loc 63
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _encodedContentDER() 0 3 2
A value() 0 3 1
A _decodeFromDER() 0 14 3
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\ASN1\Type\Primitive;
6
7
use Sop\ASN1\Component\Identifier;
8
use Sop\ASN1\Component\Length;
9
use Sop\ASN1\Element;
10
use Sop\ASN1\Exception\DecodeException;
11
use Sop\ASN1\Feature\ElementBase;
12
use Sop\ASN1\Type\PrimitiveType;
13
use Sop\ASN1\Type\UniversalClass;
14
15
/**
16
 * Implements <i>BOOLEAN</i> type.
17
 */
18
class Boolean extends Element
19
{
20
    use UniversalClass;
21
    use PrimitiveType;
22
23
    /**
24
     * Value.
25
     *
26
     * @var bool
27
     */
28
    private $_bool;
29
30
    /**
31
     * Constructor.
32
     *
33
     * @param bool $bool
34
     */
35 33
    public function __construct(bool $bool)
36
    {
37 33
        $this->_typeTag = self::TYPE_BOOLEAN;
38 33
        $this->_bool = $bool;
39 33
    }
40
41
    /**
42
     * Get the value.
43
     *
44
     * @return bool
45
     */
46 2
    public function value(): bool
47
    {
48 2
        return $this->_bool;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 6
    protected function _encodedContentDER(): string
55
    {
56 6
        return $this->_bool ? chr(0xff) : chr(0);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 8
    protected static function _decodeFromDER(Identifier $identifier,
63
        string $data, int &$offset): ElementBase
64
    {
65 8
        $idx = $offset;
66 8
        Length::expectFromDER($data, $idx, 1);
67 7
        $byte = ord($data[$idx++]);
68 7
        if (0 !== $byte) {
69 5
            if (0xff != $byte) {
70 1
                throw new DecodeException(
71 1
                    'DER encoded boolean true must have all bits set to 1.');
72
            }
73
        }
74 6
        $offset = $idx;
75 6
        return new self(0 !== $byte);
76
    }
77
}
78