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/Certificate/UniqueIdentifier.php 1 patch
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.
lib/X509/Certificate/Extensions.php 1 patch
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.
lib/X509/Certificate/Extension/KeyUsageExtension.php 1 patch
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.
lib/X509/Certificate/Extension/NoRevocationAvailableExtension.php 1 patch
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.
lib/X509/Certificate/Extension/DistributionPoint/RelativeName.php 1 patch
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.
lib/X509/Certificate/Extension/DistributionPoint/ReasonFlags.php 1 patch
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.
lib/X509/Certificate/Extension/DistributionPoint/FullName.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@
 block discarded – undo
16 16
  */
17 17
 class FullName extends DistributionPointName
18 18
 {
19
-    /**
20
-     * Names.
21
-     *
22
-     * @var GeneralNames
23
-     */
24
-    protected $_names;
19
+	/**
20
+	 * Names.
21
+	 *
22
+	 * @var GeneralNames
23
+	 */
24
+	protected $_names;
25 25
 
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param GeneralNames $names
30
-     */
31
-    public function __construct(GeneralNames $names)
32
-    {
33
-        $this->_tag = self::TAG_FULL_NAME;
34
-        $this->_names = $names;
35
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param GeneralNames $names
30
+	 */
31
+	public function __construct(GeneralNames $names)
32
+	{
33
+		$this->_tag = self::TAG_FULL_NAME;
34
+		$this->_names = $names;
35
+	}
36 36
 
37
-    /**
38
-     * Initialize with a single URI.
39
-     *
40
-     * @param string $uri
41
-     *
42
-     * @return self
43
-     */
44
-    public static function fromURI(string $uri): self
45
-    {
46
-        return new self(new GeneralNames(new UniformResourceIdentifier($uri)));
47
-    }
37
+	/**
38
+	 * Initialize with a single URI.
39
+	 *
40
+	 * @param string $uri
41
+	 *
42
+	 * @return self
43
+	 */
44
+	public static function fromURI(string $uri): self
45
+	{
46
+		return new self(new GeneralNames(new UniformResourceIdentifier($uri)));
47
+	}
48 48
 
49
-    /**
50
-     * Get names.
51
-     *
52
-     * @return GeneralNames
53
-     */
54
-    public function names(): GeneralNames
55
-    {
56
-        return $this->_names;
57
-    }
49
+	/**
50
+	 * Get names.
51
+	 *
52
+	 * @return GeneralNames
53
+	 */
54
+	public function names(): GeneralNames
55
+	{
56
+		return $this->_names;
57
+	}
58 58
 
59
-    /**
60
-     * {@inheritdoc}
61
-     */
62
-    protected function _valueASN1(): Element
63
-    {
64
-        return $this->_names->toASN1();
65
-    }
59
+	/**
60
+	 * {@inheritdoc}
61
+	 */
62
+	protected function _valueASN1(): Element
63
+	{
64
+		return $this->_names->toASN1();
65
+	}
66 66
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/DistributionPoint/DistributionPointName.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -18,65 +18,65 @@
 block discarded – undo
18 18
  */
19 19
 abstract class DistributionPointName
20 20
 {
21
-    const TAG_FULL_NAME = 0;
22
-    const TAG_RDN = 1;
21
+	const TAG_FULL_NAME = 0;
22
+	const TAG_RDN = 1;
23 23
 
24
-    /**
25
-     * Type.
26
-     *
27
-     * @var int
28
-     */
29
-    protected $_tag;
24
+	/**
25
+	 * Type.
26
+	 *
27
+	 * @var int
28
+	 */
29
+	protected $_tag;
30 30
 
31
-    /**
32
-     * Initialize from TaggedType.
33
-     *
34
-     * @param TaggedType $el
35
-     *
36
-     * @throws \UnexpectedValueException
37
-     *
38
-     * @return self
39
-     */
40
-    public static function fromTaggedType(TaggedType $el): self
41
-    {
42
-        switch ($el->tag()) {
43
-            case self::TAG_FULL_NAME:
44
-                return new FullName(
45
-                    GeneralNames::fromASN1(
46
-                        $el->asImplicit(Element::TYPE_SEQUENCE)->asSequence()));
47
-            case self::TAG_RDN:
48
-                return new RelativeName(
49
-                    RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet()));
50
-            default:
51
-                throw new \UnexpectedValueException(
52
-                    'DistributionPointName tag ' . $el->tag() . ' not supported.');
53
-        }
54
-    }
31
+	/**
32
+	 * Initialize from TaggedType.
33
+	 *
34
+	 * @param TaggedType $el
35
+	 *
36
+	 * @throws \UnexpectedValueException
37
+	 *
38
+	 * @return self
39
+	 */
40
+	public static function fromTaggedType(TaggedType $el): self
41
+	{
42
+		switch ($el->tag()) {
43
+			case self::TAG_FULL_NAME:
44
+				return new FullName(
45
+					GeneralNames::fromASN1(
46
+						$el->asImplicit(Element::TYPE_SEQUENCE)->asSequence()));
47
+			case self::TAG_RDN:
48
+				return new RelativeName(
49
+					RDN::fromASN1($el->asImplicit(Element::TYPE_SET)->asSet()));
50
+			default:
51
+				throw new \UnexpectedValueException(
52
+					'DistributionPointName tag ' . $el->tag() . ' not supported.');
53
+		}
54
+	}
55 55
 
56
-    /**
57
-     * Get type tag.
58
-     *
59
-     * @return int
60
-     */
61
-    public function tag(): int
62
-    {
63
-        return $this->_tag;
64
-    }
56
+	/**
57
+	 * Get type tag.
58
+	 *
59
+	 * @return int
60
+	 */
61
+	public function tag(): int
62
+	{
63
+		return $this->_tag;
64
+	}
65 65
 
66
-    /**
67
-     * Generate ASN.1 structure.
68
-     *
69
-     * @return ImplicitlyTaggedType
70
-     */
71
-    public function toASN1(): ImplicitlyTaggedType
72
-    {
73
-        return new ImplicitlyTaggedType($this->_tag, $this->_valueASN1());
74
-    }
66
+	/**
67
+	 * Generate ASN.1 structure.
68
+	 *
69
+	 * @return ImplicitlyTaggedType
70
+	 */
71
+	public function toASN1(): ImplicitlyTaggedType
72
+	{
73
+		return new ImplicitlyTaggedType($this->_tag, $this->_valueASN1());
74
+	}
75 75
 
76
-    /**
77
-     * Generate ASN.1 element.
78
-     *
79
-     * @return Element
80
-     */
81
-    abstract protected function _valueASN1(): Element;
76
+	/**
77
+	 * Generate ASN.1 element.
78
+	 *
79
+	 * @return Element
80
+	 */
81
+	abstract protected function _valueASN1(): Element;
82 82
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/DistributionPoint/DistributionPoint.php 1 patch
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -18,217 +18,217 @@
 block discarded – undo
18 18
  */
19 19
 class DistributionPoint
20 20
 {
21
-    /**
22
-     * Distribution point name.
23
-     *
24
-     * @var null|DistributionPointName
25
-     */
26
-    protected $_distributionPoint;
27
-
28
-    /**
29
-     * Revocation reason.
30
-     *
31
-     * @var null|ReasonFlags
32
-     */
33
-    protected $_reasons;
34
-
35
-    /**
36
-     * CRL issuer.
37
-     *
38
-     * @var null|GeneralNames
39
-     */
40
-    protected $_issuer;
41
-
42
-    /**
43
-     * Constructor.
44
-     *
45
-     * @param null|DistributionPointName $name
46
-     * @param null|ReasonFlags           $reasons
47
-     * @param null|GeneralNames          $issuer
48
-     */
49
-    public function __construct(?DistributionPointName $name = null,
50
-        ?ReasonFlags $reasons = null, ?GeneralNames $issuer = null)
51
-    {
52
-        $this->_distributionPoint = $name;
53
-        $this->_reasons = $reasons;
54
-        $this->_issuer = $issuer;
55
-    }
56
-
57
-    /**
58
-     * Initialize from ASN.1.
59
-     *
60
-     * @param Sequence $seq
61
-     *
62
-     * @return self
63
-     */
64
-    public static function fromASN1(Sequence $seq): self
65
-    {
66
-        $name = null;
67
-        $reasons = null;
68
-        $issuer = null;
69
-        if ($seq->hasTagged(0)) {
70
-            // promoted to explicit tagging because underlying type is CHOICE
71
-            $name = DistributionPointName::fromTaggedType(
72
-                $seq->getTagged(0)->asExplicit()->asTagged());
73
-        }
74
-        if ($seq->hasTagged(1)) {
75
-            $reasons = ReasonFlags::fromASN1(
76
-                $seq->getTagged(1)->asImplicit(Element::TYPE_BIT_STRING)
77
-                    ->asBitString());
78
-        }
79
-        if ($seq->hasTagged(2)) {
80
-            $issuer = GeneralNames::fromASN1(
81
-                $seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE)
82
-                    ->asSequence());
83
-        }
84
-        return new self($name, $reasons, $issuer);
85
-    }
86
-
87
-    /**
88
-     * Check whether distribution point name is set.
89
-     *
90
-     * @return bool
91
-     */
92
-    public function hasDistributionPointName(): bool
93
-    {
94
-        return isset($this->_distributionPoint);
95
-    }
96
-
97
-    /**
98
-     * Get distribution point name.
99
-     *
100
-     * @throws \LogicException If not set
101
-     *
102
-     * @return DistributionPointName
103
-     */
104
-    public function distributionPointName(): DistributionPointName
105
-    {
106
-        if (!$this->hasDistributionPointName()) {
107
-            throw new \LogicException('distributionPoint not set.');
108
-        }
109
-        return $this->_distributionPoint;
110
-    }
111
-
112
-    /**
113
-     * Check whether distribution point name is set and it's a full name.
114
-     *
115
-     * @return bool
116
-     */
117
-    public function hasFullName(): bool
118
-    {
119
-        return DistributionPointName::TAG_FULL_NAME ===
120
-             $this->distributionPointName()->tag();
121
-    }
122
-
123
-    /**
124
-     * Get full distribution point name.
125
-     *
126
-     * @throws \LogicException If not set
127
-     *
128
-     * @return FullName
129
-     */
130
-    public function fullName(): FullName
131
-    {
132
-        if (!$this->hasFullName()) {
133
-            throw new \LogicException('fullName not set.');
134
-        }
135
-        return $this->_distributionPoint;
136
-    }
137
-
138
-    /**
139
-     * Check whether distribution point name is set and it's a relative name.
140
-     *
141
-     * @return bool
142
-     */
143
-    public function hasRelativeName(): bool
144
-    {
145
-        return DistributionPointName::TAG_RDN ===
146
-             $this->distributionPointName()->tag();
147
-    }
148
-
149
-    /**
150
-     * Get relative distribution point name.
151
-     *
152
-     * @throws \LogicException If not set
153
-     *
154
-     * @return RelativeName
155
-     */
156
-    public function relativeName(): RelativeName
157
-    {
158
-        if (!$this->hasRelativeName()) {
159
-            throw new \LogicException('nameRelativeToCRLIssuer not set.');
160
-        }
161
-        return $this->_distributionPoint;
162
-    }
163
-
164
-    /**
165
-     * Check whether reasons flags is set.
166
-     *
167
-     * @return bool
168
-     */
169
-    public function hasReasons(): bool
170
-    {
171
-        return isset($this->_reasons);
172
-    }
173
-
174
-    /**
175
-     * Get revocation reason flags.
176
-     *
177
-     * @throws \LogicException If not set
178
-     *
179
-     * @return ReasonFlags
180
-     */
181
-    public function reasons(): ReasonFlags
182
-    {
183
-        if (!$this->hasReasons()) {
184
-            throw new \LogicException('reasons not set.');
185
-        }
186
-        return $this->_reasons;
187
-    }
188
-
189
-    /**
190
-     * Check whether cRLIssuer is set.
191
-     *
192
-     * @return bool
193
-     */
194
-    public function hasCRLIssuer(): bool
195
-    {
196
-        return isset($this->_issuer);
197
-    }
198
-
199
-    /**
200
-     * Get CRL issuer.
201
-     *
202
-     * @throws \LogicException If not set
203
-     *
204
-     * @return GeneralNames
205
-     */
206
-    public function crlIssuer(): GeneralNames
207
-    {
208
-        if (!$this->hasCRLIssuer()) {
209
-            throw new \LogicException('crlIssuer not set.');
210
-        }
211
-        return $this->_issuer;
212
-    }
213
-
214
-    /**
215
-     * Generate ASN.1 structure.
216
-     *
217
-     * @return Sequence
218
-     */
219
-    public function toASN1(): Sequence
220
-    {
221
-        $elements = [];
222
-        if (isset($this->_distributionPoint)) {
223
-            $elements[] = new ExplicitlyTaggedType(0,
224
-                $this->_distributionPoint->toASN1());
225
-        }
226
-        if (isset($this->_reasons)) {
227
-            $elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1());
228
-        }
229
-        if (isset($this->_issuer)) {
230
-            $elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1());
231
-        }
232
-        return new Sequence(...$elements);
233
-    }
21
+	/**
22
+	 * Distribution point name.
23
+	 *
24
+	 * @var null|DistributionPointName
25
+	 */
26
+	protected $_distributionPoint;
27
+
28
+	/**
29
+	 * Revocation reason.
30
+	 *
31
+	 * @var null|ReasonFlags
32
+	 */
33
+	protected $_reasons;
34
+
35
+	/**
36
+	 * CRL issuer.
37
+	 *
38
+	 * @var null|GeneralNames
39
+	 */
40
+	protected $_issuer;
41
+
42
+	/**
43
+	 * Constructor.
44
+	 *
45
+	 * @param null|DistributionPointName $name
46
+	 * @param null|ReasonFlags           $reasons
47
+	 * @param null|GeneralNames          $issuer
48
+	 */
49
+	public function __construct(?DistributionPointName $name = null,
50
+		?ReasonFlags $reasons = null, ?GeneralNames $issuer = null)
51
+	{
52
+		$this->_distributionPoint = $name;
53
+		$this->_reasons = $reasons;
54
+		$this->_issuer = $issuer;
55
+	}
56
+
57
+	/**
58
+	 * Initialize from ASN.1.
59
+	 *
60
+	 * @param Sequence $seq
61
+	 *
62
+	 * @return self
63
+	 */
64
+	public static function fromASN1(Sequence $seq): self
65
+	{
66
+		$name = null;
67
+		$reasons = null;
68
+		$issuer = null;
69
+		if ($seq->hasTagged(0)) {
70
+			// promoted to explicit tagging because underlying type is CHOICE
71
+			$name = DistributionPointName::fromTaggedType(
72
+				$seq->getTagged(0)->asExplicit()->asTagged());
73
+		}
74
+		if ($seq->hasTagged(1)) {
75
+			$reasons = ReasonFlags::fromASN1(
76
+				$seq->getTagged(1)->asImplicit(Element::TYPE_BIT_STRING)
77
+					->asBitString());
78
+		}
79
+		if ($seq->hasTagged(2)) {
80
+			$issuer = GeneralNames::fromASN1(
81
+				$seq->getTagged(2)->asImplicit(Element::TYPE_SEQUENCE)
82
+					->asSequence());
83
+		}
84
+		return new self($name, $reasons, $issuer);
85
+	}
86
+
87
+	/**
88
+	 * Check whether distribution point name is set.
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function hasDistributionPointName(): bool
93
+	{
94
+		return isset($this->_distributionPoint);
95
+	}
96
+
97
+	/**
98
+	 * Get distribution point name.
99
+	 *
100
+	 * @throws \LogicException If not set
101
+	 *
102
+	 * @return DistributionPointName
103
+	 */
104
+	public function distributionPointName(): DistributionPointName
105
+	{
106
+		if (!$this->hasDistributionPointName()) {
107
+			throw new \LogicException('distributionPoint not set.');
108
+		}
109
+		return $this->_distributionPoint;
110
+	}
111
+
112
+	/**
113
+	 * Check whether distribution point name is set and it's a full name.
114
+	 *
115
+	 * @return bool
116
+	 */
117
+	public function hasFullName(): bool
118
+	{
119
+		return DistributionPointName::TAG_FULL_NAME ===
120
+			 $this->distributionPointName()->tag();
121
+	}
122
+
123
+	/**
124
+	 * Get full distribution point name.
125
+	 *
126
+	 * @throws \LogicException If not set
127
+	 *
128
+	 * @return FullName
129
+	 */
130
+	public function fullName(): FullName
131
+	{
132
+		if (!$this->hasFullName()) {
133
+			throw new \LogicException('fullName not set.');
134
+		}
135
+		return $this->_distributionPoint;
136
+	}
137
+
138
+	/**
139
+	 * Check whether distribution point name is set and it's a relative name.
140
+	 *
141
+	 * @return bool
142
+	 */
143
+	public function hasRelativeName(): bool
144
+	{
145
+		return DistributionPointName::TAG_RDN ===
146
+			 $this->distributionPointName()->tag();
147
+	}
148
+
149
+	/**
150
+	 * Get relative distribution point name.
151
+	 *
152
+	 * @throws \LogicException If not set
153
+	 *
154
+	 * @return RelativeName
155
+	 */
156
+	public function relativeName(): RelativeName
157
+	{
158
+		if (!$this->hasRelativeName()) {
159
+			throw new \LogicException('nameRelativeToCRLIssuer not set.');
160
+		}
161
+		return $this->_distributionPoint;
162
+	}
163
+
164
+	/**
165
+	 * Check whether reasons flags is set.
166
+	 *
167
+	 * @return bool
168
+	 */
169
+	public function hasReasons(): bool
170
+	{
171
+		return isset($this->_reasons);
172
+	}
173
+
174
+	/**
175
+	 * Get revocation reason flags.
176
+	 *
177
+	 * @throws \LogicException If not set
178
+	 *
179
+	 * @return ReasonFlags
180
+	 */
181
+	public function reasons(): ReasonFlags
182
+	{
183
+		if (!$this->hasReasons()) {
184
+			throw new \LogicException('reasons not set.');
185
+		}
186
+		return $this->_reasons;
187
+	}
188
+
189
+	/**
190
+	 * Check whether cRLIssuer is set.
191
+	 *
192
+	 * @return bool
193
+	 */
194
+	public function hasCRLIssuer(): bool
195
+	{
196
+		return isset($this->_issuer);
197
+	}
198
+
199
+	/**
200
+	 * Get CRL issuer.
201
+	 *
202
+	 * @throws \LogicException If not set
203
+	 *
204
+	 * @return GeneralNames
205
+	 */
206
+	public function crlIssuer(): GeneralNames
207
+	{
208
+		if (!$this->hasCRLIssuer()) {
209
+			throw new \LogicException('crlIssuer not set.');
210
+		}
211
+		return $this->_issuer;
212
+	}
213
+
214
+	/**
215
+	 * Generate ASN.1 structure.
216
+	 *
217
+	 * @return Sequence
218
+	 */
219
+	public function toASN1(): Sequence
220
+	{
221
+		$elements = [];
222
+		if (isset($this->_distributionPoint)) {
223
+			$elements[] = new ExplicitlyTaggedType(0,
224
+				$this->_distributionPoint->toASN1());
225
+		}
226
+		if (isset($this->_reasons)) {
227
+			$elements[] = new ImplicitlyTaggedType(1, $this->_reasons->toASN1());
228
+		}
229
+		if (isset($this->_issuer)) {
230
+			$elements[] = new ImplicitlyTaggedType(2, $this->_issuer->toASN1());
231
+		}
232
+		return new Sequence(...$elements);
233
+	}
234 234
 }
Please login to merge, or discard this patch.