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.
Completed
Branch php72 (a7f01e)
by Joni
04:53
created

ReasonFlags::__construct()   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
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 <i>ReasonFlags</i> ASN.1 type used by
12
 * 'CRL Distribution Points' 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
     */
52 12
    public static function fromASN1(BitString $bs): self
53
    {
54 12
        return new self(Flags::fromBitString($bs, 9)->intNumber());
55
    }
56
57
    /**
58
     * Check whether keyCompromise flag is set.
59
     *
60
     * @return bool
61
     */
62 3
    public function isKeyCompromise(): bool
63
    {
64 3
        return $this->_flagSet(self::KEY_COMPROMISE);
65
    }
66
67
    /**
68
     * Check whether cACompromise flag is set.
69
     *
70
     * @return bool
71
     */
72 3
    public function isCACompromise(): bool
73
    {
74 3
        return $this->_flagSet(self::CA_COMPROMISE);
75
    }
76
77
    /**
78
     * Check whether affiliationChanged flag is set.
79
     *
80
     * @return bool
81
     */
82 3
    public function isAffiliationChanged(): bool
83
    {
84 3
        return $this->_flagSet(self::AFFILIATION_CHANGED);
85
    }
86
87
    /**
88
     * Check whether superseded flag is set.
89
     *
90
     * @return bool
91
     */
92 3
    public function isSuperseded(): bool
93
    {
94 3
        return $this->_flagSet(self::SUPERSEDED);
95
    }
96
97
    /**
98
     * Check whether cessationOfOperation flag is set.
99
     *
100
     * @return bool
101
     */
102 3
    public function isCessationOfOperation(): bool
103
    {
104 3
        return $this->_flagSet(self::CESSATION_OF_OPERATION);
105
    }
106
107
    /**
108
     * Check whether certificateHold flag is set.
109
     *
110
     * @return bool
111
     */
112 3
    public function isCertificateHold(): bool
113
    {
114 3
        return $this->_flagSet(self::CERTIFICATE_HOLD);
115
    }
116
117
    /**
118
     * Check whether privilegeWithdrawn flag is set.
119
     *
120
     * @return bool
121
     */
122 4
    public function isPrivilegeWithdrawn(): bool
123
    {
124 4
        return $this->_flagSet(self::PRIVILEGE_WITHDRAWN);
125
    }
126
127
    /**
128
     * Check whether aACompromise flag is set.
129
     *
130
     * @return bool
131
     */
132 3
    public function isAACompromise(): bool
133
    {
134 3
        return $this->_flagSet(self::AA_COMPROMISE);
135
    }
136
137
    /**
138
     * Generate ASN.1 element.
139
     *
140
     * @return BitString
141
     */
142 18
    public function toASN1(): BitString
143
    {
144 18
        $flags = new Flags($this->_flags, 9);
145 18
        return $flags->bitString()->withoutTrailingZeroes();
146
    }
147
148
    /**
149
     * Check whether given flag is set.
150
     *
151
     * @param int $flag
152
     *
153
     * @return bool
154
     */
155 11
    protected function _flagSet(int $flag): bool
156
    {
157 11
        return (bool) ($this->_flags & $flag);
158
    }
159
}
160