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.
Test Failed
Push — master ( 405cf3...79c9ba )
by Joni
04:48
created

ReasonFlags::isCertificateHold()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\X509\Certificate\Extension\DistributionPoint;
6
7
use Sop\ASN1\Type\Primitive\BitString;
8
use Sop\ASN1\Util\Flags;
9
10
/**
11
 * Implements *ReasonFlags* ASN.1 type used by 'CRL Distribution Points'
12
 * certificate extension.
13
 *
14
 * @see https://tools.ietf.org/html/rfc5280#section-4.2.1.13
15
 */
16
class ReasonFlags
17
{
18
    // const UNUSED = 0x100;
19
    const KEY_COMPROMISE = 0x080;
20
    const CA_COMPROMISE = 0x040;
21
    const AFFILIATION_CHANGED = 0x020;
22
    const SUPERSEDED = 0x010;
23
    const CESSATION_OF_OPERATION = 0x008;
24
    const CERTIFICATE_HOLD = 0x004;
25
    const PRIVILEGE_WITHDRAWN = 0x002;
26
    const AA_COMPROMISE = 0x001;
27
28
    /**
29
     * Flags.
30
     *
31
     * @var int
32
     */
33
    protected $_flags;
34
35
    /**
36
     * Constructor.
37
     *
38
     * @param int $flags
39
     */
40 15
    public function __construct(int $flags)
41
    {
42 15
        $this->_flags = $flags;
43 15
    }
44
45
    /**
46
     * Initialize from ASN.1.
47
     *
48
     * @param BitString $bs
49
     *
50
     * @return self
51 12
     */
52
    public static function fromASN1(BitString $bs): self
53 12
    {
54
        return new self(Flags::fromBitString($bs, 9)->intNumber());
55
    }
56
57
    /**
58
     * Check whether keyCompromise flag is set.
59
     *
60
     * @return bool
61 3
     */
62
    public function isKeyCompromise(): bool
63 3
    {
64
        return $this->_flagSet(self::KEY_COMPROMISE);
65
    }
66
67
    /**
68
     * Check whether cACompromise flag is set.
69
     *
70
     * @return bool
71 3
     */
72
    public function isCACompromise(): bool
73 3
    {
74
        return $this->_flagSet(self::CA_COMPROMISE);
75
    }
76
77
    /**
78
     * Check whether affiliationChanged flag is set.
79
     *
80
     * @return bool
81 3
     */
82
    public function isAffiliationChanged(): bool
83 3
    {
84
        return $this->_flagSet(self::AFFILIATION_CHANGED);
85
    }
86
87
    /**
88
     * Check whether superseded flag is set.
89
     *
90
     * @return bool
91 3
     */
92
    public function isSuperseded(): bool
93 3
    {
94
        return $this->_flagSet(self::SUPERSEDED);
95
    }
96
97
    /**
98
     * Check whether cessationOfOperation flag is set.
99
     *
100
     * @return bool
101 3
     */
102
    public function isCessationOfOperation(): bool
103 3
    {
104
        return $this->_flagSet(self::CESSATION_OF_OPERATION);
105
    }
106
107
    /**
108
     * Check whether certificateHold flag is set.
109
     *
110
     * @return bool
111 3
     */
112
    public function isCertificateHold(): bool
113 3
    {
114
        return $this->_flagSet(self::CERTIFICATE_HOLD);
115
    }
116
117
    /**
118
     * Check whether privilegeWithdrawn flag is set.
119
     *
120
     * @return bool
121 4
     */
122
    public function isPrivilegeWithdrawn(): bool
123 4
    {
124
        return $this->_flagSet(self::PRIVILEGE_WITHDRAWN);
125
    }
126
127
    /**
128
     * Check whether aACompromise flag is set.
129
     *
130
     * @return bool
131 3
     */
132
    public function isAACompromise(): bool
133 3
    {
134
        return $this->_flagSet(self::AA_COMPROMISE);
135
    }
136
137
    /**
138
     * Generate ASN.1 element.
139
     *
140
     * @return BitString
141 18
     */
142
    public function toASN1(): BitString
143 18
    {
144 18
        $flags = new Flags($this->_flags, 9);
145
        return $flags->bitString()->withoutTrailingZeroes();
146
    }
147
148
    /**
149
     * Check whether given flag is set.
150
     *
151
     * @param int $flag
152
     *
153 11
     * @return bool
154
     */
155 11
    protected function _flagSet(int $flag): bool
156
    {
157
        return (bool) ($this->_flags & $flag);
158
    }
159
}
160