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
lib/X509/GeneralName/X400Address.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -19,44 +19,44 @@
 block discarded – undo
19 19
  */
20 20
 class X400Address extends GeneralName
21 21
 {
22
-    /**
23
-     * @var \Sop\ASN1\Element
24
-     */
25
-    protected $_element;
26
-
27
-    /**
28
-     * Constructor.
29
-     */
30
-    protected function __construct()
31
-    {
32
-        $this->_tag = self::TAG_X400_ADDRESS;
33
-    }
34
-
35
-    /**
36
-     * {@inheritdoc}
37
-     *
38
-     * @return self
39
-     */
40
-    public static function fromChosenASN1(UnspecifiedType $el): GeneralName
41
-    {
42
-        $obj = new self();
43
-        $obj->_element = $el->asSequence();
44
-        return $obj;
45
-    }
46
-
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function string(): string
51
-    {
52
-        return bin2hex($this->_element->toDER());
53
-    }
54
-
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    protected function _choiceASN1(): TaggedType
59
-    {
60
-        return new ImplicitlyTaggedType($this->_tag, $this->_element);
61
-    }
22
+	/**
23
+	 * @var \Sop\ASN1\Element
24
+	 */
25
+	protected $_element;
26
+
27
+	/**
28
+	 * Constructor.
29
+	 */
30
+	protected function __construct()
31
+	{
32
+		$this->_tag = self::TAG_X400_ADDRESS;
33
+	}
34
+
35
+	/**
36
+	 * {@inheritdoc}
37
+	 *
38
+	 * @return self
39
+	 */
40
+	public static function fromChosenASN1(UnspecifiedType $el): GeneralName
41
+	{
42
+		$obj = new self();
43
+		$obj->_element = $el->asSequence();
44
+		return $obj;
45
+	}
46
+
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	public function string(): string
51
+	{
52
+		return bin2hex($this->_element->toDER());
53
+	}
54
+
55
+	/**
56
+	 * {@inheritdoc}
57
+	 */
58
+	protected function _choiceASN1(): TaggedType
59
+	{
60
+		return new ImplicitlyTaggedType($this->_tag, $this->_element);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\GeneralName;
6 6
 
Please login to merge, or discard this patch.
lib/X509/GeneralName/RFC822Name.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,57 +16,57 @@
 block discarded – undo
16 16
  */
17 17
 class RFC822Name extends GeneralName
18 18
 {
19
-    /**
20
-     * Email.
21
-     *
22
-     * @var string
23
-     */
24
-    protected $_email;
19
+	/**
20
+	 * Email.
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $_email;
25 25
 
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param string $email
30
-     */
31
-    public function __construct(string $email)
32
-    {
33
-        $this->_tag = self::TAG_RFC822_NAME;
34
-        $this->_email = $email;
35
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param string $email
30
+	 */
31
+	public function __construct(string $email)
32
+	{
33
+		$this->_tag = self::TAG_RFC822_NAME;
34
+		$this->_email = $email;
35
+	}
36 36
 
37
-    /**
38
-     * {@inheritdoc}
39
-     *
40
-     * @return self
41
-     */
42
-    public static function fromChosenASN1(UnspecifiedType $el): GeneralName
43
-    {
44
-        return new self($el->asIA5String()->string());
45
-    }
37
+	/**
38
+	 * {@inheritdoc}
39
+	 *
40
+	 * @return self
41
+	 */
42
+	public static function fromChosenASN1(UnspecifiedType $el): GeneralName
43
+	{
44
+		return new self($el->asIA5String()->string());
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function string(): string
51
-    {
52
-        return $this->_email;
53
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	public function string(): string
51
+	{
52
+		return $this->_email;
53
+	}
54 54
 
55
-    /**
56
-     * Get email.
57
-     *
58
-     * @return string
59
-     */
60
-    public function email(): string
61
-    {
62
-        return $this->_email;
63
-    }
55
+	/**
56
+	 * Get email.
57
+	 *
58
+	 * @return string
59
+	 */
60
+	public function email(): string
61
+	{
62
+		return $this->_email;
63
+	}
64 64
 
65
-    /**
66
-     * {@inheritdoc}
67
-     */
68
-    protected function _choiceASN1(): TaggedType
69
-    {
70
-        return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_email));
71
-    }
65
+	/**
66
+	 * {@inheritdoc}
67
+	 */
68
+	protected function _choiceASN1(): TaggedType
69
+	{
70
+		return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_email));
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\GeneralName;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Validity.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,88 +13,88 @@
 block discarded – undo
13 13
  */
14 14
 class Validity
15 15
 {
16
-    /**
17
-     * Not before time.
18
-     *
19
-     * @var Time
20
-     */
21
-    protected $_notBefore;
16
+	/**
17
+	 * Not before time.
18
+	 *
19
+	 * @var Time
20
+	 */
21
+	protected $_notBefore;
22 22
 
23
-    /**
24
-     * Not after time.
25
-     *
26
-     * @var Time
27
-     */
28
-    protected $_notAfter;
23
+	/**
24
+	 * Not after time.
25
+	 *
26
+	 * @var Time
27
+	 */
28
+	protected $_notAfter;
29 29
 
30
-    /**
31
-     * Constructor.
32
-     *
33
-     * @param Time $not_before
34
-     * @param Time $not_after
35
-     */
36
-    public function __construct(Time $not_before, Time $not_after)
37
-    {
38
-        $this->_notBefore = $not_before;
39
-        $this->_notAfter = $not_after;
40
-    }
30
+	/**
31
+	 * Constructor.
32
+	 *
33
+	 * @param Time $not_before
34
+	 * @param Time $not_after
35
+	 */
36
+	public function __construct(Time $not_before, Time $not_after)
37
+	{
38
+		$this->_notBefore = $not_before;
39
+		$this->_notAfter = $not_after;
40
+	}
41 41
 
42
-    /**
43
-     * Initialize from ASN.1.
44
-     *
45
-     * @param Sequence $seq
46
-     */
47
-    public static function fromASN1(Sequence $seq): self
48
-    {
49
-        $nb = Time::fromASN1($seq->at(0)->asTime());
50
-        $na = Time::fromASN1($seq->at(1)->asTime());
51
-        return new self($nb, $na);
52
-    }
42
+	/**
43
+	 * Initialize from ASN.1.
44
+	 *
45
+	 * @param Sequence $seq
46
+	 */
47
+	public static function fromASN1(Sequence $seq): self
48
+	{
49
+		$nb = Time::fromASN1($seq->at(0)->asTime());
50
+		$na = Time::fromASN1($seq->at(1)->asTime());
51
+		return new self($nb, $na);
52
+	}
53 53
 
54
-    /**
55
-     * Initialize from date strings.
56
-     *
57
-     * @param null|string $nb_date Not before date
58
-     * @param null|string $na_date Not after date
59
-     * @param null|string $tz      Timezone string
60
-     *
61
-     * @return self
62
-     */
63
-    public static function fromStrings(?string $nb_date, ?string $na_date,
64
-        ?string $tz = null): self
65
-    {
66
-        return new self(Time::fromString($nb_date, $tz),
67
-            Time::fromString($na_date, $tz));
68
-    }
54
+	/**
55
+	 * Initialize from date strings.
56
+	 *
57
+	 * @param null|string $nb_date Not before date
58
+	 * @param null|string $na_date Not after date
59
+	 * @param null|string $tz      Timezone string
60
+	 *
61
+	 * @return self
62
+	 */
63
+	public static function fromStrings(?string $nb_date, ?string $na_date,
64
+		?string $tz = null): self
65
+	{
66
+		return new self(Time::fromString($nb_date, $tz),
67
+			Time::fromString($na_date, $tz));
68
+	}
69 69
 
70
-    /**
71
-     * Get not before time.
72
-     *
73
-     * @return Time
74
-     */
75
-    public function notBefore(): Time
76
-    {
77
-        return $this->_notBefore;
78
-    }
70
+	/**
71
+	 * Get not before time.
72
+	 *
73
+	 * @return Time
74
+	 */
75
+	public function notBefore(): Time
76
+	{
77
+		return $this->_notBefore;
78
+	}
79 79
 
80
-    /**
81
-     * Get not after time.
82
-     *
83
-     * @return Time
84
-     */
85
-    public function notAfter(): Time
86
-    {
87
-        return $this->_notAfter;
88
-    }
80
+	/**
81
+	 * Get not after time.
82
+	 *
83
+	 * @return Time
84
+	 */
85
+	public function notAfter(): Time
86
+	{
87
+		return $this->_notAfter;
88
+	}
89 89
 
90
-    /**
91
-     * Generate ASN.1 structure.
92
-     *
93
-     * @return Sequence
94
-     */
95
-    public function toASN1(): Sequence
96
-    {
97
-        return new Sequence($this->_notBefore->toASN1(),
98
-            $this->_notAfter->toASN1());
99
-    }
90
+	/**
91
+	 * Generate ASN.1 structure.
92
+	 *
93
+	 * @return Sequence
94
+	 */
95
+	public function toASN1(): Sequence
96
+	{
97
+		return new Sequence($this->_notBefore->toASN1(),
98
+			$this->_notAfter->toASN1());
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/UniqueIdentifier.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -13,74 +13,74 @@
 block discarded – undo
13 13
  */
14 14
 class UniqueIdentifier
15 15
 {
16
-    /**
17
-     * Identifier.
18
-     *
19
-     * @var BitString
20
-     */
21
-    protected $_uid;
16
+	/**
17
+	 * Identifier.
18
+	 *
19
+	 * @var BitString
20
+	 */
21
+	protected $_uid;
22 22
 
23
-    /**
24
-     * Constructor.
25
-     *
26
-     * @param BitString $bs
27
-     */
28
-    public function __construct(BitString $bs)
29
-    {
30
-        $this->_uid = $bs;
31
-    }
23
+	/**
24
+	 * Constructor.
25
+	 *
26
+	 * @param BitString $bs
27
+	 */
28
+	public function __construct(BitString $bs)
29
+	{
30
+		$this->_uid = $bs;
31
+	}
32 32
 
33
-    /**
34
-     * Initialize from ASN.1.
35
-     *
36
-     * @param BitString $bs
37
-     *
38
-     * @return self
39
-     */
40
-    public static function fromASN1(BitString $bs): UniqueIdentifier
41
-    {
42
-        return new self($bs);
43
-    }
33
+	/**
34
+	 * Initialize from ASN.1.
35
+	 *
36
+	 * @param BitString $bs
37
+	 *
38
+	 * @return self
39
+	 */
40
+	public static function fromASN1(BitString $bs): UniqueIdentifier
41
+	{
42
+		return new self($bs);
43
+	}
44 44
 
45
-    /**
46
-     * Initialize from string.
47
-     *
48
-     * @param string $str
49
-     *
50
-     * @return self
51
-     */
52
-    public static function fromString(string $str): UniqueIdentifier
53
-    {
54
-        return new self(new BitString($str));
55
-    }
45
+	/**
46
+	 * Initialize from string.
47
+	 *
48
+	 * @param string $str
49
+	 *
50
+	 * @return self
51
+	 */
52
+	public static function fromString(string $str): UniqueIdentifier
53
+	{
54
+		return new self(new BitString($str));
55
+	}
56 56
 
57
-    /**
58
-     * Get unique identifier as a string.
59
-     *
60
-     * @return string
61
-     */
62
-    public function string(): string
63
-    {
64
-        return $this->_uid->string();
65
-    }
57
+	/**
58
+	 * Get unique identifier as a string.
59
+	 *
60
+	 * @return string
61
+	 */
62
+	public function string(): string
63
+	{
64
+		return $this->_uid->string();
65
+	}
66 66
 
67
-    /**
68
-     * Get unique identifier as a bit string.
69
-     *
70
-     * @return BitString
71
-     */
72
-    public function bitString(): BitString
73
-    {
74
-        return $this->_uid;
75
-    }
67
+	/**
68
+	 * Get unique identifier as a bit string.
69
+	 *
70
+	 * @return BitString
71
+	 */
72
+	public function bitString(): BitString
73
+	{
74
+		return $this->_uid;
75
+	}
76 76
 
77
-    /**
78
-     * Get ASN.1 element.
79
-     *
80
-     * @return BitString
81
-     */
82
-    public function toASN1(): BitString
83
-    {
84
-        return $this->_uid;
85
-    }
77
+	/**
78
+	 * Get ASN.1 element.
79
+	 *
80
+	 * @return BitString
81
+	 */
82
+	public function toASN1(): BitString
83
+	{
84
+		return $this->_uid;
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extensions.php 2 patches
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -31,405 +31,405 @@
 block discarded – undo
31 31
  */
32 32
 class Extensions implements \Countable, \IteratorAggregate
33 33
 {
34
-    /**
35
-     * Extensions.
36
-     *
37
-     * @var Extension[]
38
-     */
39
-    protected $_extensions;
40
-
41
-    /**
42
-     * Constructor.
43
-     *
44
-     * @param Extension ...$extensions Extension objects
45
-     */
46
-    public function __construct(Extension ...$extensions)
47
-    {
48
-        $this->_extensions = [];
49
-        foreach ($extensions as $ext) {
50
-            $this->_extensions[$ext->oid()] = $ext;
51
-        }
52
-    }
53
-
54
-    /**
55
-     * Initialize from ASN.1.
56
-     *
57
-     * @param Sequence $seq
58
-     *
59
-     * @return self
60
-     */
61
-    public static function fromASN1(Sequence $seq): Extensions
62
-    {
63
-        $extensions = array_map(
64
-            function (UnspecifiedType $el) {
65
-                return Extension::fromASN1($el->asSequence());
66
-            }, $seq->elements());
67
-        return new self(...$extensions);
68
-    }
69
-
70
-    /**
71
-     * Generate ASN.1 structure.
72
-     *
73
-     * @return Sequence
74
-     */
75
-    public function toASN1(): Sequence
76
-    {
77
-        $elements = array_values(
78
-            array_map(
79
-                function ($ext) {
80
-                    return $ext->toASN1();
81
-                }, $this->_extensions));
82
-        return new Sequence(...$elements);
83
-    }
84
-
85
-    /**
86
-     * Get self with extensions added.
87
-     *
88
-     * @param Extension ...$exts One or more extensions to add
89
-     *
90
-     * @return self
91
-     */
92
-    public function withExtensions(Extension ...$exts): Extensions
93
-    {
94
-        $obj = clone $this;
95
-        foreach ($exts as $ext) {
96
-            $obj->_extensions[$ext->oid()] = $ext;
97
-        }
98
-        return $obj;
99
-    }
100
-
101
-    /**
102
-     * Check whether extension is present.
103
-     *
104
-     * @param string $oid Extensions OID
105
-     *
106
-     * @return bool
107
-     */
108
-    public function has(string $oid): bool
109
-    {
110
-        return isset($this->_extensions[$oid]);
111
-    }
112
-
113
-    /**
114
-     * Get extension by OID.
115
-     *
116
-     * @param string $oid
117
-     *
118
-     * @throws \LogicException If extension is not present
119
-     *
120
-     * @return Extension
121
-     */
122
-    public function get(string $oid): Extension
123
-    {
124
-        if (!$this->has($oid)) {
125
-            throw new \LogicException("No extension by OID {$oid}.");
126
-        }
127
-        return $this->_extensions[$oid];
128
-    }
129
-
130
-    /**
131
-     * Check whether 'Authority Key Identifier' extension is present.
132
-     *
133
-     * @return bool
134
-     */
135
-    public function hasAuthorityKeyIdentifier(): bool
136
-    {
137
-        return $this->has(Extension::OID_AUTHORITY_KEY_IDENTIFIER);
138
-    }
139
-
140
-    /**
141
-     * Get 'Authority Key Identifier' extension.
142
-     *
143
-     * @throws \LogicException If extension is not present
144
-     *
145
-     * @return AuthorityKeyIdentifierExtension
146
-     */
147
-    public function authorityKeyIdentifier(): AuthorityKeyIdentifierExtension
148
-    {
149
-        return $this->get(Extension::OID_AUTHORITY_KEY_IDENTIFIER);
150
-    }
151
-
152
-    /**
153
-     * Check whether 'Subject Key Identifier' extension is present.
154
-     *
155
-     * @return bool
156
-     */
157
-    public function hasSubjectKeyIdentifier(): bool
158
-    {
159
-        return $this->has(Extension::OID_SUBJECT_KEY_IDENTIFIER);
160
-    }
161
-
162
-    /**
163
-     * Get 'Subject Key Identifier' extension.
164
-     *
165
-     * @throws \LogicException If extension is not present
166
-     *
167
-     * @return SubjectKeyIdentifierExtension
168
-     */
169
-    public function subjectKeyIdentifier(): SubjectKeyIdentifierExtension
170
-    {
171
-        return $this->get(Extension::OID_SUBJECT_KEY_IDENTIFIER);
172
-    }
173
-
174
-    /**
175
-     * Check whether 'Key Usage' extension is present.
176
-     *
177
-     * @return bool
178
-     */
179
-    public function hasKeyUsage(): bool
180
-    {
181
-        return $this->has(Extension::OID_KEY_USAGE);
182
-    }
183
-
184
-    /**
185
-     * Get 'Key Usage' extension.
186
-     *
187
-     * @throws \LogicException If extension is not present
188
-     *
189
-     * @return KeyUsageExtension
190
-     */
191
-    public function keyUsage(): KeyUsageExtension
192
-    {
193
-        return $this->get(Extension::OID_KEY_USAGE);
194
-    }
195
-
196
-    /**
197
-     * Check whether 'Certificate Policies' extension is present.
198
-     *
199
-     * @return bool
200
-     */
201
-    public function hasCertificatePolicies(): bool
202
-    {
203
-        return $this->has(Extension::OID_CERTIFICATE_POLICIES);
204
-    }
205
-
206
-    /**
207
-     * Get 'Certificate Policies' extension.
208
-     *
209
-     * @throws \LogicException If extension is not present
210
-     *
211
-     * @return CertificatePoliciesExtension
212
-     */
213
-    public function certificatePolicies(): CertificatePoliciesExtension
214
-    {
215
-        return $this->get(Extension::OID_CERTIFICATE_POLICIES);
216
-    }
217
-
218
-    /**
219
-     * Check whether 'Policy Mappings' extension is present.
220
-     *
221
-     * @return bool
222
-     */
223
-    public function hasPolicyMappings(): bool
224
-    {
225
-        return $this->has(Extension::OID_POLICY_MAPPINGS);
226
-    }
227
-
228
-    /**
229
-     * Get 'Policy Mappings' extension.
230
-     *
231
-     * @throws \LogicException If extension is not present
232
-     *
233
-     * @return PolicyMappingsExtension
234
-     */
235
-    public function policyMappings(): PolicyMappingsExtension
236
-    {
237
-        return $this->get(Extension::OID_POLICY_MAPPINGS);
238
-    }
239
-
240
-    /**
241
-     * Check whether 'Subject Alternative Name' extension is present.
242
-     *
243
-     * @return bool
244
-     */
245
-    public function hasSubjectAlternativeName(): bool
246
-    {
247
-        return $this->has(Extension::OID_SUBJECT_ALT_NAME);
248
-    }
249
-
250
-    /**
251
-     * Get 'Subject Alternative Name' extension.
252
-     *
253
-     * @throws \LogicException If extension is not present
254
-     *
255
-     * @return SubjectAlternativeNameExtension
256
-     */
257
-    public function subjectAlternativeName(): SubjectAlternativeNameExtension
258
-    {
259
-        return $this->get(Extension::OID_SUBJECT_ALT_NAME);
260
-    }
261
-
262
-    /**
263
-     * Check whether 'Issuer Alternative Name' extension is present.
264
-     *
265
-     * @return bool
266
-     */
267
-    public function hasIssuerAlternativeName(): bool
268
-    {
269
-        return $this->has(Extension::OID_ISSUER_ALT_NAME);
270
-    }
271
-
272
-    /**
273
-     * Get 'Issuer Alternative Name' extension.
274
-     *
275
-     * @return IssuerAlternativeNameExtension
276
-     */
277
-    public function issuerAlternativeName(): IssuerAlternativeNameExtension
278
-    {
279
-        return $this->get(Extension::OID_ISSUER_ALT_NAME);
280
-    }
281
-
282
-    /**
283
-     * Check whether 'Basic Constraints' extension is present.
284
-     *
285
-     * @return bool
286
-     */
287
-    public function hasBasicConstraints(): bool
288
-    {
289
-        return $this->has(Extension::OID_BASIC_CONSTRAINTS);
290
-    }
291
-
292
-    /**
293
-     * Get 'Basic Constraints' extension.
294
-     *
295
-     * @throws \LogicException If extension is not present
296
-     *
297
-     * @return BasicConstraintsExtension
298
-     */
299
-    public function basicConstraints(): BasicConstraintsExtension
300
-    {
301
-        return $this->get(Extension::OID_BASIC_CONSTRAINTS);
302
-    }
303
-
304
-    /**
305
-     * Check whether 'Name Constraints' extension is present.
306
-     *
307
-     * @return bool
308
-     */
309
-    public function hasNameConstraints(): bool
310
-    {
311
-        return $this->has(Extension::OID_NAME_CONSTRAINTS);
312
-    }
313
-
314
-    /**
315
-     * Get 'Name Constraints' extension.
316
-     *
317
-     * @throws \LogicException If extension is not present
318
-     *
319
-     * @return NameConstraintsExtension
320
-     */
321
-    public function nameConstraints(): NameConstraintsExtension
322
-    {
323
-        return $this->get(Extension::OID_NAME_CONSTRAINTS);
324
-    }
325
-
326
-    /**
327
-     * Check whether 'Policy Constraints' extension is present.
328
-     *
329
-     * @return bool
330
-     */
331
-    public function hasPolicyConstraints(): bool
332
-    {
333
-        return $this->has(Extension::OID_POLICY_CONSTRAINTS);
334
-    }
335
-
336
-    /**
337
-     * Get 'Policy Constraints' extension.
338
-     *
339
-     * @throws \LogicException If extension is not present
340
-     *
341
-     * @return PolicyConstraintsExtension
342
-     */
343
-    public function policyConstraints(): PolicyConstraintsExtension
344
-    {
345
-        return $this->get(Extension::OID_POLICY_CONSTRAINTS);
346
-    }
347
-
348
-    /**
349
-     * Check whether 'Extended Key Usage' extension is present.
350
-     *
351
-     * @return bool
352
-     */
353
-    public function hasExtendedKeyUsage(): bool
354
-    {
355
-        return $this->has(Extension::OID_EXT_KEY_USAGE);
356
-    }
357
-
358
-    /**
359
-     * Get 'Extended Key Usage' extension.
360
-     *
361
-     * @throws \LogicException If extension is not present
362
-     *
363
-     * @return ExtendedKeyUsageExtension
364
-     */
365
-    public function extendedKeyUsage(): ExtendedKeyUsageExtension
366
-    {
367
-        return $this->get(Extension::OID_EXT_KEY_USAGE);
368
-    }
369
-
370
-    /**
371
-     * Check whether 'CRL Distribution Points' extension is present.
372
-     *
373
-     * @return bool
374
-     */
375
-    public function hasCRLDistributionPoints(): bool
376
-    {
377
-        return $this->has(Extension::OID_CRL_DISTRIBUTION_POINTS);
378
-    }
379
-
380
-    /**
381
-     * Get 'CRL Distribution Points' extension.
382
-     *
383
-     * @throws \LogicException If extension is not present
384
-     *
385
-     * @return CRLDistributionPointsExtension
386
-     */
387
-    public function crlDistributionPoints(): CRLDistributionPointsExtension
388
-    {
389
-        return $this->get(Extension::OID_CRL_DISTRIBUTION_POINTS);
390
-    }
391
-
392
-    /**
393
-     * Check whether 'Inhibit anyPolicy' extension is present.
394
-     *
395
-     * @return bool
396
-     */
397
-    public function hasInhibitAnyPolicy(): bool
398
-    {
399
-        return $this->has(Extension::OID_INHIBIT_ANY_POLICY);
400
-    }
401
-
402
-    /**
403
-     * Get 'Inhibit anyPolicy' extension.
404
-     *
405
-     * @throws \LogicException If extension is not present
406
-     *
407
-     * @return InhibitAnyPolicyExtension
408
-     */
409
-    public function inhibitAnyPolicy(): InhibitAnyPolicyExtension
410
-    {
411
-        return $this->get(Extension::OID_INHIBIT_ANY_POLICY);
412
-    }
413
-
414
-    /**
415
-     * @see \Countable::count()
416
-     *
417
-     * @return int
418
-     */
419
-    public function count(): int
420
-    {
421
-        return count($this->_extensions);
422
-    }
423
-
424
-    /**
425
-     * Get iterator for extensions.
426
-     *
427
-     * @see \IteratorAggregate::getIterator()
428
-     *
429
-     * @return \Traversable
430
-     */
431
-    public function getIterator(): \Traversable
432
-    {
433
-        return new \ArrayIterator($this->_extensions);
434
-    }
34
+	/**
35
+	 * Extensions.
36
+	 *
37
+	 * @var Extension[]
38
+	 */
39
+	protected $_extensions;
40
+
41
+	/**
42
+	 * Constructor.
43
+	 *
44
+	 * @param Extension ...$extensions Extension objects
45
+	 */
46
+	public function __construct(Extension ...$extensions)
47
+	{
48
+		$this->_extensions = [];
49
+		foreach ($extensions as $ext) {
50
+			$this->_extensions[$ext->oid()] = $ext;
51
+		}
52
+	}
53
+
54
+	/**
55
+	 * Initialize from ASN.1.
56
+	 *
57
+	 * @param Sequence $seq
58
+	 *
59
+	 * @return self
60
+	 */
61
+	public static function fromASN1(Sequence $seq): Extensions
62
+	{
63
+		$extensions = array_map(
64
+			function (UnspecifiedType $el) {
65
+				return Extension::fromASN1($el->asSequence());
66
+			}, $seq->elements());
67
+		return new self(...$extensions);
68
+	}
69
+
70
+	/**
71
+	 * Generate ASN.1 structure.
72
+	 *
73
+	 * @return Sequence
74
+	 */
75
+	public function toASN1(): Sequence
76
+	{
77
+		$elements = array_values(
78
+			array_map(
79
+				function ($ext) {
80
+					return $ext->toASN1();
81
+				}, $this->_extensions));
82
+		return new Sequence(...$elements);
83
+	}
84
+
85
+	/**
86
+	 * Get self with extensions added.
87
+	 *
88
+	 * @param Extension ...$exts One or more extensions to add
89
+	 *
90
+	 * @return self
91
+	 */
92
+	public function withExtensions(Extension ...$exts): Extensions
93
+	{
94
+		$obj = clone $this;
95
+		foreach ($exts as $ext) {
96
+			$obj->_extensions[$ext->oid()] = $ext;
97
+		}
98
+		return $obj;
99
+	}
100
+
101
+	/**
102
+	 * Check whether extension is present.
103
+	 *
104
+	 * @param string $oid Extensions OID
105
+	 *
106
+	 * @return bool
107
+	 */
108
+	public function has(string $oid): bool
109
+	{
110
+		return isset($this->_extensions[$oid]);
111
+	}
112
+
113
+	/**
114
+	 * Get extension by OID.
115
+	 *
116
+	 * @param string $oid
117
+	 *
118
+	 * @throws \LogicException If extension is not present
119
+	 *
120
+	 * @return Extension
121
+	 */
122
+	public function get(string $oid): Extension
123
+	{
124
+		if (!$this->has($oid)) {
125
+			throw new \LogicException("No extension by OID {$oid}.");
126
+		}
127
+		return $this->_extensions[$oid];
128
+	}
129
+
130
+	/**
131
+	 * Check whether 'Authority Key Identifier' extension is present.
132
+	 *
133
+	 * @return bool
134
+	 */
135
+	public function hasAuthorityKeyIdentifier(): bool
136
+	{
137
+		return $this->has(Extension::OID_AUTHORITY_KEY_IDENTIFIER);
138
+	}
139
+
140
+	/**
141
+	 * Get 'Authority Key Identifier' extension.
142
+	 *
143
+	 * @throws \LogicException If extension is not present
144
+	 *
145
+	 * @return AuthorityKeyIdentifierExtension
146
+	 */
147
+	public function authorityKeyIdentifier(): AuthorityKeyIdentifierExtension
148
+	{
149
+		return $this->get(Extension::OID_AUTHORITY_KEY_IDENTIFIER);
150
+	}
151
+
152
+	/**
153
+	 * Check whether 'Subject Key Identifier' extension is present.
154
+	 *
155
+	 * @return bool
156
+	 */
157
+	public function hasSubjectKeyIdentifier(): bool
158
+	{
159
+		return $this->has(Extension::OID_SUBJECT_KEY_IDENTIFIER);
160
+	}
161
+
162
+	/**
163
+	 * Get 'Subject Key Identifier' extension.
164
+	 *
165
+	 * @throws \LogicException If extension is not present
166
+	 *
167
+	 * @return SubjectKeyIdentifierExtension
168
+	 */
169
+	public function subjectKeyIdentifier(): SubjectKeyIdentifierExtension
170
+	{
171
+		return $this->get(Extension::OID_SUBJECT_KEY_IDENTIFIER);
172
+	}
173
+
174
+	/**
175
+	 * Check whether 'Key Usage' extension is present.
176
+	 *
177
+	 * @return bool
178
+	 */
179
+	public function hasKeyUsage(): bool
180
+	{
181
+		return $this->has(Extension::OID_KEY_USAGE);
182
+	}
183
+
184
+	/**
185
+	 * Get 'Key Usage' extension.
186
+	 *
187
+	 * @throws \LogicException If extension is not present
188
+	 *
189
+	 * @return KeyUsageExtension
190
+	 */
191
+	public function keyUsage(): KeyUsageExtension
192
+	{
193
+		return $this->get(Extension::OID_KEY_USAGE);
194
+	}
195
+
196
+	/**
197
+	 * Check whether 'Certificate Policies' extension is present.
198
+	 *
199
+	 * @return bool
200
+	 */
201
+	public function hasCertificatePolicies(): bool
202
+	{
203
+		return $this->has(Extension::OID_CERTIFICATE_POLICIES);
204
+	}
205
+
206
+	/**
207
+	 * Get 'Certificate Policies' extension.
208
+	 *
209
+	 * @throws \LogicException If extension is not present
210
+	 *
211
+	 * @return CertificatePoliciesExtension
212
+	 */
213
+	public function certificatePolicies(): CertificatePoliciesExtension
214
+	{
215
+		return $this->get(Extension::OID_CERTIFICATE_POLICIES);
216
+	}
217
+
218
+	/**
219
+	 * Check whether 'Policy Mappings' extension is present.
220
+	 *
221
+	 * @return bool
222
+	 */
223
+	public function hasPolicyMappings(): bool
224
+	{
225
+		return $this->has(Extension::OID_POLICY_MAPPINGS);
226
+	}
227
+
228
+	/**
229
+	 * Get 'Policy Mappings' extension.
230
+	 *
231
+	 * @throws \LogicException If extension is not present
232
+	 *
233
+	 * @return PolicyMappingsExtension
234
+	 */
235
+	public function policyMappings(): PolicyMappingsExtension
236
+	{
237
+		return $this->get(Extension::OID_POLICY_MAPPINGS);
238
+	}
239
+
240
+	/**
241
+	 * Check whether 'Subject Alternative Name' extension is present.
242
+	 *
243
+	 * @return bool
244
+	 */
245
+	public function hasSubjectAlternativeName(): bool
246
+	{
247
+		return $this->has(Extension::OID_SUBJECT_ALT_NAME);
248
+	}
249
+
250
+	/**
251
+	 * Get 'Subject Alternative Name' extension.
252
+	 *
253
+	 * @throws \LogicException If extension is not present
254
+	 *
255
+	 * @return SubjectAlternativeNameExtension
256
+	 */
257
+	public function subjectAlternativeName(): SubjectAlternativeNameExtension
258
+	{
259
+		return $this->get(Extension::OID_SUBJECT_ALT_NAME);
260
+	}
261
+
262
+	/**
263
+	 * Check whether 'Issuer Alternative Name' extension is present.
264
+	 *
265
+	 * @return bool
266
+	 */
267
+	public function hasIssuerAlternativeName(): bool
268
+	{
269
+		return $this->has(Extension::OID_ISSUER_ALT_NAME);
270
+	}
271
+
272
+	/**
273
+	 * Get 'Issuer Alternative Name' extension.
274
+	 *
275
+	 * @return IssuerAlternativeNameExtension
276
+	 */
277
+	public function issuerAlternativeName(): IssuerAlternativeNameExtension
278
+	{
279
+		return $this->get(Extension::OID_ISSUER_ALT_NAME);
280
+	}
281
+
282
+	/**
283
+	 * Check whether 'Basic Constraints' extension is present.
284
+	 *
285
+	 * @return bool
286
+	 */
287
+	public function hasBasicConstraints(): bool
288
+	{
289
+		return $this->has(Extension::OID_BASIC_CONSTRAINTS);
290
+	}
291
+
292
+	/**
293
+	 * Get 'Basic Constraints' extension.
294
+	 *
295
+	 * @throws \LogicException If extension is not present
296
+	 *
297
+	 * @return BasicConstraintsExtension
298
+	 */
299
+	public function basicConstraints(): BasicConstraintsExtension
300
+	{
301
+		return $this->get(Extension::OID_BASIC_CONSTRAINTS);
302
+	}
303
+
304
+	/**
305
+	 * Check whether 'Name Constraints' extension is present.
306
+	 *
307
+	 * @return bool
308
+	 */
309
+	public function hasNameConstraints(): bool
310
+	{
311
+		return $this->has(Extension::OID_NAME_CONSTRAINTS);
312
+	}
313
+
314
+	/**
315
+	 * Get 'Name Constraints' extension.
316
+	 *
317
+	 * @throws \LogicException If extension is not present
318
+	 *
319
+	 * @return NameConstraintsExtension
320
+	 */
321
+	public function nameConstraints(): NameConstraintsExtension
322
+	{
323
+		return $this->get(Extension::OID_NAME_CONSTRAINTS);
324
+	}
325
+
326
+	/**
327
+	 * Check whether 'Policy Constraints' extension is present.
328
+	 *
329
+	 * @return bool
330
+	 */
331
+	public function hasPolicyConstraints(): bool
332
+	{
333
+		return $this->has(Extension::OID_POLICY_CONSTRAINTS);
334
+	}
335
+
336
+	/**
337
+	 * Get 'Policy Constraints' extension.
338
+	 *
339
+	 * @throws \LogicException If extension is not present
340
+	 *
341
+	 * @return PolicyConstraintsExtension
342
+	 */
343
+	public function policyConstraints(): PolicyConstraintsExtension
344
+	{
345
+		return $this->get(Extension::OID_POLICY_CONSTRAINTS);
346
+	}
347
+
348
+	/**
349
+	 * Check whether 'Extended Key Usage' extension is present.
350
+	 *
351
+	 * @return bool
352
+	 */
353
+	public function hasExtendedKeyUsage(): bool
354
+	{
355
+		return $this->has(Extension::OID_EXT_KEY_USAGE);
356
+	}
357
+
358
+	/**
359
+	 * Get 'Extended Key Usage' extension.
360
+	 *
361
+	 * @throws \LogicException If extension is not present
362
+	 *
363
+	 * @return ExtendedKeyUsageExtension
364
+	 */
365
+	public function extendedKeyUsage(): ExtendedKeyUsageExtension
366
+	{
367
+		return $this->get(Extension::OID_EXT_KEY_USAGE);
368
+	}
369
+
370
+	/**
371
+	 * Check whether 'CRL Distribution Points' extension is present.
372
+	 *
373
+	 * @return bool
374
+	 */
375
+	public function hasCRLDistributionPoints(): bool
376
+	{
377
+		return $this->has(Extension::OID_CRL_DISTRIBUTION_POINTS);
378
+	}
379
+
380
+	/**
381
+	 * Get 'CRL Distribution Points' extension.
382
+	 *
383
+	 * @throws \LogicException If extension is not present
384
+	 *
385
+	 * @return CRLDistributionPointsExtension
386
+	 */
387
+	public function crlDistributionPoints(): CRLDistributionPointsExtension
388
+	{
389
+		return $this->get(Extension::OID_CRL_DISTRIBUTION_POINTS);
390
+	}
391
+
392
+	/**
393
+	 * Check whether 'Inhibit anyPolicy' extension is present.
394
+	 *
395
+	 * @return bool
396
+	 */
397
+	public function hasInhibitAnyPolicy(): bool
398
+	{
399
+		return $this->has(Extension::OID_INHIBIT_ANY_POLICY);
400
+	}
401
+
402
+	/**
403
+	 * Get 'Inhibit anyPolicy' extension.
404
+	 *
405
+	 * @throws \LogicException If extension is not present
406
+	 *
407
+	 * @return InhibitAnyPolicyExtension
408
+	 */
409
+	public function inhibitAnyPolicy(): InhibitAnyPolicyExtension
410
+	{
411
+		return $this->get(Extension::OID_INHIBIT_ANY_POLICY);
412
+	}
413
+
414
+	/**
415
+	 * @see \Countable::count()
416
+	 *
417
+	 * @return int
418
+	 */
419
+	public function count(): int
420
+	{
421
+		return count($this->_extensions);
422
+	}
423
+
424
+	/**
425
+	 * Get iterator for extensions.
426
+	 *
427
+	 * @see \IteratorAggregate::getIterator()
428
+	 *
429
+	 * @return \Traversable
430
+	 */
431
+	public function getIterator(): \Traversable
432
+	{
433
+		return new \ArrayIterator($this->_extensions);
434
+	}
435 435
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate;
6 6
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public static function fromASN1(Sequence $seq): Extensions
62 62
     {
63 63
         $extensions = array_map(
64
-            function (UnspecifiedType $el) {
64
+            function(UnspecifiedType $el) {
65 65
                 return Extension::fromASN1($el->asSequence());
66 66
             }, $seq->elements());
67 67
         return new self(...$extensions);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $elements = array_values(
78 78
             array_map(
79
-                function ($ext) {
79
+                function($ext) {
80 80
                     return $ext->toASN1();
81 81
                 }, $this->_extensions));
82 82
         return new Sequence(...$elements);
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/KeyUsageExtension.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -15,153 +15,153 @@
 block discarded – undo
15 15
  */
16 16
 class KeyUsageExtension extends Extension
17 17
 {
18
-    const DIGITAL_SIGNATURE = 0x100;
19
-    const NON_REPUDIATION = 0x080;
20
-    const KEY_ENCIPHERMENT = 0x040;
21
-    const DATA_ENCIPHERMENT = 0x020;
22
-    const KEY_AGREEMENT = 0x010;
23
-    const KEY_CERT_SIGN = 0x008;
24
-    const CRL_SIGN = 0x004;
25
-    const ENCIPHER_ONLY = 0x002;
26
-    const DECIPHER_ONLY = 0x001;
27
-
28
-    /**
29
-     * Key usage flags.
30
-     *
31
-     * @var int
32
-     */
33
-    protected $_keyUsage;
34
-
35
-    /**
36
-     * Constructor.
37
-     *
38
-     * @param bool $critical
39
-     * @param int  $keyUsage
40
-     */
41
-    public function __construct(bool $critical, int $keyUsage)
42
-    {
43
-        parent::__construct(self::OID_KEY_USAGE, $critical);
44
-        $this->_keyUsage = $keyUsage;
45
-    }
46
-
47
-    /**
48
-     * Check whether digitalSignature flag is set.
49
-     *
50
-     * @return bool
51
-     */
52
-    public function isDigitalSignature(): bool
53
-    {
54
-        return $this->_flagSet(self::DIGITAL_SIGNATURE);
55
-    }
56
-
57
-    /**
58
-     * Check whether nonRepudiation/contentCommitment flag is set.
59
-     *
60
-     * @return bool
61
-     */
62
-    public function isNonRepudiation(): bool
63
-    {
64
-        return $this->_flagSet(self::NON_REPUDIATION);
65
-    }
66
-
67
-    /**
68
-     * Check whether keyEncipherment flag is set.
69
-     *
70
-     * @return bool
71
-     */
72
-    public function isKeyEncipherment(): bool
73
-    {
74
-        return $this->_flagSet(self::KEY_ENCIPHERMENT);
75
-    }
76
-
77
-    /**
78
-     * Check whether dataEncipherment flag is set.
79
-     *
80
-     * @return bool
81
-     */
82
-    public function isDataEncipherment(): bool
83
-    {
84
-        return $this->_flagSet(self::DATA_ENCIPHERMENT);
85
-    }
86
-
87
-    /**
88
-     * Check whether keyAgreement flag is set.
89
-     *
90
-     * @return bool
91
-     */
92
-    public function isKeyAgreement(): bool
93
-    {
94
-        return $this->_flagSet(self::KEY_AGREEMENT);
95
-    }
96
-
97
-    /**
98
-     * Check whether keyCertSign flag is set.
99
-     *
100
-     * @return bool
101
-     */
102
-    public function isKeyCertSign(): bool
103
-    {
104
-        return $this->_flagSet(self::KEY_CERT_SIGN);
105
-    }
106
-
107
-    /**
108
-     * Check whether cRLSign flag is set.
109
-     *
110
-     * @return bool
111
-     */
112
-    public function isCRLSign(): bool
113
-    {
114
-        return $this->_flagSet(self::CRL_SIGN);
115
-    }
116
-
117
-    /**
118
-     * Check whether encipherOnly flag is set.
119
-     *
120
-     * @return bool
121
-     */
122
-    public function isEncipherOnly(): bool
123
-    {
124
-        return $this->_flagSet(self::ENCIPHER_ONLY);
125
-    }
126
-
127
-    /**
128
-     * Check whether decipherOnly flag is set.
129
-     *
130
-     * @return bool
131
-     */
132
-    public function isDecipherOnly(): bool
133
-    {
134
-        return $this->_flagSet(self::DECIPHER_ONLY);
135
-    }
136
-
137
-    /**
138
-     * Check whether given flag is set.
139
-     *
140
-     * @param int $flag
141
-     *
142
-     * @return bool
143
-     */
144
-    protected function _flagSet(int $flag): bool
145
-    {
146
-        return (bool) ($this->_keyUsage & $flag);
147
-    }
148
-
149
-    /**
150
-     * {@inheritdoc}
151
-     */
152
-    protected static function _fromDER(string $data, bool $critical): Extension
153
-    {
154
-        return new self($critical,
155
-            Flags::fromBitString(
156
-                UnspecifiedType::fromDER($data)->asBitString(), 9)->intNumber());
157
-    }
158
-
159
-    /**
160
-     * {@inheritdoc}
161
-     */
162
-    protected function _valueASN1(): Element
163
-    {
164
-        $flags = new Flags($this->_keyUsage, 9);
165
-        return $flags->bitString()->withoutTrailingZeroes();
166
-    }
18
+	const DIGITAL_SIGNATURE = 0x100;
19
+	const NON_REPUDIATION = 0x080;
20
+	const KEY_ENCIPHERMENT = 0x040;
21
+	const DATA_ENCIPHERMENT = 0x020;
22
+	const KEY_AGREEMENT = 0x010;
23
+	const KEY_CERT_SIGN = 0x008;
24
+	const CRL_SIGN = 0x004;
25
+	const ENCIPHER_ONLY = 0x002;
26
+	const DECIPHER_ONLY = 0x001;
27
+
28
+	/**
29
+	 * Key usage flags.
30
+	 *
31
+	 * @var int
32
+	 */
33
+	protected $_keyUsage;
34
+
35
+	/**
36
+	 * Constructor.
37
+	 *
38
+	 * @param bool $critical
39
+	 * @param int  $keyUsage
40
+	 */
41
+	public function __construct(bool $critical, int $keyUsage)
42
+	{
43
+		parent::__construct(self::OID_KEY_USAGE, $critical);
44
+		$this->_keyUsage = $keyUsage;
45
+	}
46
+
47
+	/**
48
+	 * Check whether digitalSignature flag is set.
49
+	 *
50
+	 * @return bool
51
+	 */
52
+	public function isDigitalSignature(): bool
53
+	{
54
+		return $this->_flagSet(self::DIGITAL_SIGNATURE);
55
+	}
56
+
57
+	/**
58
+	 * Check whether nonRepudiation/contentCommitment flag is set.
59
+	 *
60
+	 * @return bool
61
+	 */
62
+	public function isNonRepudiation(): bool
63
+	{
64
+		return $this->_flagSet(self::NON_REPUDIATION);
65
+	}
66
+
67
+	/**
68
+	 * Check whether keyEncipherment flag is set.
69
+	 *
70
+	 * @return bool
71
+	 */
72
+	public function isKeyEncipherment(): bool
73
+	{
74
+		return $this->_flagSet(self::KEY_ENCIPHERMENT);
75
+	}
76
+
77
+	/**
78
+	 * Check whether dataEncipherment flag is set.
79
+	 *
80
+	 * @return bool
81
+	 */
82
+	public function isDataEncipherment(): bool
83
+	{
84
+		return $this->_flagSet(self::DATA_ENCIPHERMENT);
85
+	}
86
+
87
+	/**
88
+	 * Check whether keyAgreement flag is set.
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function isKeyAgreement(): bool
93
+	{
94
+		return $this->_flagSet(self::KEY_AGREEMENT);
95
+	}
96
+
97
+	/**
98
+	 * Check whether keyCertSign flag is set.
99
+	 *
100
+	 * @return bool
101
+	 */
102
+	public function isKeyCertSign(): bool
103
+	{
104
+		return $this->_flagSet(self::KEY_CERT_SIGN);
105
+	}
106
+
107
+	/**
108
+	 * Check whether cRLSign flag is set.
109
+	 *
110
+	 * @return bool
111
+	 */
112
+	public function isCRLSign(): bool
113
+	{
114
+		return $this->_flagSet(self::CRL_SIGN);
115
+	}
116
+
117
+	/**
118
+	 * Check whether encipherOnly flag is set.
119
+	 *
120
+	 * @return bool
121
+	 */
122
+	public function isEncipherOnly(): bool
123
+	{
124
+		return $this->_flagSet(self::ENCIPHER_ONLY);
125
+	}
126
+
127
+	/**
128
+	 * Check whether decipherOnly flag is set.
129
+	 *
130
+	 * @return bool
131
+	 */
132
+	public function isDecipherOnly(): bool
133
+	{
134
+		return $this->_flagSet(self::DECIPHER_ONLY);
135
+	}
136
+
137
+	/**
138
+	 * Check whether given flag is set.
139
+	 *
140
+	 * @param int $flag
141
+	 *
142
+	 * @return bool
143
+	 */
144
+	protected function _flagSet(int $flag): bool
145
+	{
146
+		return (bool) ($this->_keyUsage & $flag);
147
+	}
148
+
149
+	/**
150
+	 * {@inheritdoc}
151
+	 */
152
+	protected static function _fromDER(string $data, bool $critical): Extension
153
+	{
154
+		return new self($critical,
155
+			Flags::fromBitString(
156
+				UnspecifiedType::fromDER($data)->asBitString(), 9)->intNumber());
157
+	}
158
+
159
+	/**
160
+	 * {@inheritdoc}
161
+	 */
162
+	protected function _valueASN1(): Element
163
+	{
164
+		$flags = new Flags($this->_keyUsage, 9);
165
+		return $flags->bitString()->withoutTrailingZeroes();
166
+	}
167 167
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/NoRevocationAvailableExtension.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@
 block discarded – undo
14 14
  */
15 15
 class NoRevocationAvailableExtension extends Extension
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param bool $critical
21
-     */
22
-    public function __construct(bool $critical)
23
-    {
24
-        parent::__construct(self::OID_NO_REV_AVAIL, $critical);
25
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param bool $critical
21
+	 */
22
+	public function __construct(bool $critical)
23
+	{
24
+		parent::__construct(self::OID_NO_REV_AVAIL, $critical);
25
+	}
26 26
 
27
-    /**
28
-     * {@inheritdoc}
29
-     */
30
-    protected static function _fromDER(string $data, bool $critical): Extension
31
-    {
32
-        NullType::fromDER($data);
33
-        return new self($critical);
34
-    }
27
+	/**
28
+	 * {@inheritdoc}
29
+	 */
30
+	protected static function _fromDER(string $data, bool $critical): Extension
31
+	{
32
+		NullType::fromDER($data);
33
+		return new self($critical);
34
+	}
35 35
 
36
-    /**
37
-     * {@inheritdoc}
38
-     */
39
-    protected function _valueASN1(): Element
40
-    {
41
-        return new NullType();
42
-    }
36
+	/**
37
+	 * {@inheritdoc}
38
+	 */
39
+	protected function _valueASN1(): Element
40
+	{
41
+		return new NullType();
42
+	}
43 43
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/DistributionPoint/RelativeName.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
  */
17 17
 class RelativeName extends DistributionPointName
18 18
 {
19
-    /**
20
-     * Relative distinguished name.
21
-     *
22
-     * @var RDN
23
-     */
24
-    protected $_rdn;
19
+	/**
20
+	 * Relative distinguished name.
21
+	 *
22
+	 * @var RDN
23
+	 */
24
+	protected $_rdn;
25 25
 
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param RDN $rdn
30
-     */
31
-    public function __construct(RDN $rdn)
32
-    {
33
-        $this->_tag = self::TAG_RDN;
34
-        $this->_rdn = $rdn;
35
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param RDN $rdn
30
+	 */
31
+	public function __construct(RDN $rdn)
32
+	{
33
+		$this->_tag = self::TAG_RDN;
34
+		$this->_rdn = $rdn;
35
+	}
36 36
 
37
-    /**
38
-     * Get RDN.
39
-     *
40
-     * @return RDN
41
-     */
42
-    public function rdn(): RDN
43
-    {
44
-        return $this->_rdn;
45
-    }
37
+	/**
38
+	 * Get RDN.
39
+	 *
40
+	 * @return RDN
41
+	 */
42
+	public function rdn(): RDN
43
+	{
44
+		return $this->_rdn;
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    protected function _valueASN1(): Element
51
-    {
52
-        return $this->_rdn->toASN1();
53
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	protected function _valueASN1(): Element
51
+	{
52
+		return $this->_rdn->toASN1();
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension\DistributionPoint;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/DistributionPoint/ReasonFlags.php 2 patches
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -15,145 +15,145 @@
 block discarded – undo
15 15
  */
16 16
 class ReasonFlags
17 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
-    public function __construct(int $flags)
41
-    {
42
-        $this->_flags = $flags;
43
-    }
44
-
45
-    /**
46
-     * Initialize from ASN.1.
47
-     *
48
-     * @param BitString $bs
49
-     *
50
-     * @return self
51
-     */
52
-    public static function fromASN1(BitString $bs): self
53
-    {
54
-        return new self(Flags::fromBitString($bs, 9)->intNumber());
55
-    }
56
-
57
-    /**
58
-     * Check whether keyCompromise flag is set.
59
-     *
60
-     * @return bool
61
-     */
62
-    public function isKeyCompromise(): bool
63
-    {
64
-        return $this->_flagSet(self::KEY_COMPROMISE);
65
-    }
66
-
67
-    /**
68
-     * Check whether cACompromise flag is set.
69
-     *
70
-     * @return bool
71
-     */
72
-    public function isCACompromise(): bool
73
-    {
74
-        return $this->_flagSet(self::CA_COMPROMISE);
75
-    }
76
-
77
-    /**
78
-     * Check whether affiliationChanged flag is set.
79
-     *
80
-     * @return bool
81
-     */
82
-    public function isAffiliationChanged(): bool
83
-    {
84
-        return $this->_flagSet(self::AFFILIATION_CHANGED);
85
-    }
86
-
87
-    /**
88
-     * Check whether superseded flag is set.
89
-     *
90
-     * @return bool
91
-     */
92
-    public function isSuperseded(): bool
93
-    {
94
-        return $this->_flagSet(self::SUPERSEDED);
95
-    }
96
-
97
-    /**
98
-     * Check whether cessationOfOperation flag is set.
99
-     *
100
-     * @return bool
101
-     */
102
-    public function isCessationOfOperation(): bool
103
-    {
104
-        return $this->_flagSet(self::CESSATION_OF_OPERATION);
105
-    }
106
-
107
-    /**
108
-     * Check whether certificateHold flag is set.
109
-     *
110
-     * @return bool
111
-     */
112
-    public function isCertificateHold(): bool
113
-    {
114
-        return $this->_flagSet(self::CERTIFICATE_HOLD);
115
-    }
116
-
117
-    /**
118
-     * Check whether privilegeWithdrawn flag is set.
119
-     *
120
-     * @return bool
121
-     */
122
-    public function isPrivilegeWithdrawn(): bool
123
-    {
124
-        return $this->_flagSet(self::PRIVILEGE_WITHDRAWN);
125
-    }
126
-
127
-    /**
128
-     * Check whether aACompromise flag is set.
129
-     *
130
-     * @return bool
131
-     */
132
-    public function isAACompromise(): bool
133
-    {
134
-        return $this->_flagSet(self::AA_COMPROMISE);
135
-    }
136
-
137
-    /**
138
-     * Generate ASN.1 element.
139
-     *
140
-     * @return BitString
141
-     */
142
-    public function toASN1(): BitString
143
-    {
144
-        $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
-     * @return bool
154
-     */
155
-    protected function _flagSet(int $flag): bool
156
-    {
157
-        return (bool) ($this->_flags & $flag);
158
-    }
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
+	public function __construct(int $flags)
41
+	{
42
+		$this->_flags = $flags;
43
+	}
44
+
45
+	/**
46
+	 * Initialize from ASN.1.
47
+	 *
48
+	 * @param BitString $bs
49
+	 *
50
+	 * @return self
51
+	 */
52
+	public static function fromASN1(BitString $bs): self
53
+	{
54
+		return new self(Flags::fromBitString($bs, 9)->intNumber());
55
+	}
56
+
57
+	/**
58
+	 * Check whether keyCompromise flag is set.
59
+	 *
60
+	 * @return bool
61
+	 */
62
+	public function isKeyCompromise(): bool
63
+	{
64
+		return $this->_flagSet(self::KEY_COMPROMISE);
65
+	}
66
+
67
+	/**
68
+	 * Check whether cACompromise flag is set.
69
+	 *
70
+	 * @return bool
71
+	 */
72
+	public function isCACompromise(): bool
73
+	{
74
+		return $this->_flagSet(self::CA_COMPROMISE);
75
+	}
76
+
77
+	/**
78
+	 * Check whether affiliationChanged flag is set.
79
+	 *
80
+	 * @return bool
81
+	 */
82
+	public function isAffiliationChanged(): bool
83
+	{
84
+		return $this->_flagSet(self::AFFILIATION_CHANGED);
85
+	}
86
+
87
+	/**
88
+	 * Check whether superseded flag is set.
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function isSuperseded(): bool
93
+	{
94
+		return $this->_flagSet(self::SUPERSEDED);
95
+	}
96
+
97
+	/**
98
+	 * Check whether cessationOfOperation flag is set.
99
+	 *
100
+	 * @return bool
101
+	 */
102
+	public function isCessationOfOperation(): bool
103
+	{
104
+		return $this->_flagSet(self::CESSATION_OF_OPERATION);
105
+	}
106
+
107
+	/**
108
+	 * Check whether certificateHold flag is set.
109
+	 *
110
+	 * @return bool
111
+	 */
112
+	public function isCertificateHold(): bool
113
+	{
114
+		return $this->_flagSet(self::CERTIFICATE_HOLD);
115
+	}
116
+
117
+	/**
118
+	 * Check whether privilegeWithdrawn flag is set.
119
+	 *
120
+	 * @return bool
121
+	 */
122
+	public function isPrivilegeWithdrawn(): bool
123
+	{
124
+		return $this->_flagSet(self::PRIVILEGE_WITHDRAWN);
125
+	}
126
+
127
+	/**
128
+	 * Check whether aACompromise flag is set.
129
+	 *
130
+	 * @return bool
131
+	 */
132
+	public function isAACompromise(): bool
133
+	{
134
+		return $this->_flagSet(self::AA_COMPROMISE);
135
+	}
136
+
137
+	/**
138
+	 * Generate ASN.1 element.
139
+	 *
140
+	 * @return BitString
141
+	 */
142
+	public function toASN1(): BitString
143
+	{
144
+		$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
+	 * @return bool
154
+	 */
155
+	protected function _flagSet(int $flag): bool
156
+	{
157
+		return (bool) ($this->_flags & $flag);
158
+	}
159 159
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension\DistributionPoint;
6 6
 
Please login to merge, or discard this patch.