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.

Boolean::_encodedContentDER()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
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 *BOOLEAN* 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 33
    public function __construct(bool $bool)
34
    {
35 33
        $this->_typeTag = self::TYPE_BOOLEAN;
36 33
        $this->_bool = $bool;
37 33
    }
38
39
    /**
40
     * Get the value.
41
     */
42 2
    public function value(): bool
43
    {
44 2
        return $this->_bool;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 6
    protected function _encodedContentDER(): string
51
    {
52 6
        return $this->_bool ? chr(0xff) : chr(0);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 8
    protected static function _decodeFromDER(Identifier $identifier,
59
        string $data, int &$offset): ElementBase
60
    {
61 8
        $idx = $offset;
62 8
        Length::expectFromDER($data, $idx, 1);
63 7
        $byte = ord($data[$idx++]);
64 7
        if (0 !== $byte) {
65 5
            if (0xff !== $byte) {
66 1
                throw new DecodeException(
67 1
                    'DER encoded boolean true must have all bits set to 1.');
68
            }
69
        }
70 6
        $offset = $idx;
71 6
        return new self(0 !== $byte);
72
    }
73
}
74