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 — master ( 95c197...564e5e )
by Joni
04:32
created

Boolean::value()   A

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\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
     * @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