@@ -15,156 +15,156 @@ |
||
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; |
|
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 | 27 | |
28 | - /** |
|
29 | - * Key usage flags. |
|
30 | - * |
|
31 | - * @var int $_keyUsage |
|
32 | - */ |
|
33 | - protected $_keyUsage; |
|
28 | + /** |
|
29 | + * Key usage flags. |
|
30 | + * |
|
31 | + * @var int $_keyUsage |
|
32 | + */ |
|
33 | + protected $_keyUsage; |
|
34 | 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 | - } |
|
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 | 46 | |
47 | - /** |
|
48 | - * |
|
49 | - * {@inheritdoc} |
|
50 | - * @return self |
|
51 | - */ |
|
52 | - protected static function _fromDER(string $data, bool $critical): self |
|
53 | - { |
|
54 | - return new self($critical, |
|
55 | - Flags::fromBitString(UnspecifiedType::fromDER($data)->asBitString(), |
|
56 | - 9)->intNumber()); |
|
57 | - } |
|
47 | + /** |
|
48 | + * |
|
49 | + * {@inheritdoc} |
|
50 | + * @return self |
|
51 | + */ |
|
52 | + protected static function _fromDER(string $data, bool $critical): self |
|
53 | + { |
|
54 | + return new self($critical, |
|
55 | + Flags::fromBitString(UnspecifiedType::fromDER($data)->asBitString(), |
|
56 | + 9)->intNumber()); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Check whether digitalSignature flag is set. |
|
61 | - * |
|
62 | - * @return bool |
|
63 | - */ |
|
64 | - public function isDigitalSignature(): bool |
|
65 | - { |
|
66 | - return $this->_flagSet(self::DIGITAL_SIGNATURE); |
|
67 | - } |
|
59 | + /** |
|
60 | + * Check whether digitalSignature flag is set. |
|
61 | + * |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | + public function isDigitalSignature(): bool |
|
65 | + { |
|
66 | + return $this->_flagSet(self::DIGITAL_SIGNATURE); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Check whether nonRepudiation/contentCommitment flag is set. |
|
71 | - * |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - public function isNonRepudiation(): bool |
|
75 | - { |
|
76 | - return $this->_flagSet(self::NON_REPUDIATION); |
|
77 | - } |
|
69 | + /** |
|
70 | + * Check whether nonRepudiation/contentCommitment flag is set. |
|
71 | + * |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + public function isNonRepudiation(): bool |
|
75 | + { |
|
76 | + return $this->_flagSet(self::NON_REPUDIATION); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Check whether keyEncipherment flag is set. |
|
81 | - * |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - public function isKeyEncipherment(): bool |
|
85 | - { |
|
86 | - return $this->_flagSet(self::KEY_ENCIPHERMENT); |
|
87 | - } |
|
79 | + /** |
|
80 | + * Check whether keyEncipherment flag is set. |
|
81 | + * |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + public function isKeyEncipherment(): bool |
|
85 | + { |
|
86 | + return $this->_flagSet(self::KEY_ENCIPHERMENT); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Check whether dataEncipherment flag is set. |
|
91 | - * |
|
92 | - * @return bool |
|
93 | - */ |
|
94 | - public function isDataEncipherment(): bool |
|
95 | - { |
|
96 | - return $this->_flagSet(self::DATA_ENCIPHERMENT); |
|
97 | - } |
|
89 | + /** |
|
90 | + * Check whether dataEncipherment flag is set. |
|
91 | + * |
|
92 | + * @return bool |
|
93 | + */ |
|
94 | + public function isDataEncipherment(): bool |
|
95 | + { |
|
96 | + return $this->_flagSet(self::DATA_ENCIPHERMENT); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Check whether keyAgreement flag is set. |
|
101 | - * |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - public function isKeyAgreement(): bool |
|
105 | - { |
|
106 | - return $this->_flagSet(self::KEY_AGREEMENT); |
|
107 | - } |
|
99 | + /** |
|
100 | + * Check whether keyAgreement flag is set. |
|
101 | + * |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + public function isKeyAgreement(): bool |
|
105 | + { |
|
106 | + return $this->_flagSet(self::KEY_AGREEMENT); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Check whether keyCertSign flag is set. |
|
111 | - * |
|
112 | - * @return bool |
|
113 | - */ |
|
114 | - public function isKeyCertSign(): bool |
|
115 | - { |
|
116 | - return $this->_flagSet(self::KEY_CERT_SIGN); |
|
117 | - } |
|
109 | + /** |
|
110 | + * Check whether keyCertSign flag is set. |
|
111 | + * |
|
112 | + * @return bool |
|
113 | + */ |
|
114 | + public function isKeyCertSign(): bool |
|
115 | + { |
|
116 | + return $this->_flagSet(self::KEY_CERT_SIGN); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Check whether cRLSign flag is set. |
|
121 | - * |
|
122 | - * @return bool |
|
123 | - */ |
|
124 | - public function isCRLSign(): bool |
|
125 | - { |
|
126 | - return $this->_flagSet(self::CRL_SIGN); |
|
127 | - } |
|
119 | + /** |
|
120 | + * Check whether cRLSign flag is set. |
|
121 | + * |
|
122 | + * @return bool |
|
123 | + */ |
|
124 | + public function isCRLSign(): bool |
|
125 | + { |
|
126 | + return $this->_flagSet(self::CRL_SIGN); |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * Check whether encipherOnly flag is set. |
|
131 | - * |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - public function isEncipherOnly(): bool |
|
135 | - { |
|
136 | - return $this->_flagSet(self::ENCIPHER_ONLY); |
|
137 | - } |
|
129 | + /** |
|
130 | + * Check whether encipherOnly flag is set. |
|
131 | + * |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + public function isEncipherOnly(): bool |
|
135 | + { |
|
136 | + return $this->_flagSet(self::ENCIPHER_ONLY); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Check whether decipherOnly flag is set. |
|
141 | - * |
|
142 | - * @return bool |
|
143 | - */ |
|
144 | - public function isDecipherOnly(): bool |
|
145 | - { |
|
146 | - return $this->_flagSet(self::DECIPHER_ONLY); |
|
147 | - } |
|
139 | + /** |
|
140 | + * Check whether decipherOnly flag is set. |
|
141 | + * |
|
142 | + * @return bool |
|
143 | + */ |
|
144 | + public function isDecipherOnly(): bool |
|
145 | + { |
|
146 | + return $this->_flagSet(self::DECIPHER_ONLY); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Check whether given flag is set. |
|
151 | - * |
|
152 | - * @param int $flag |
|
153 | - * @return boolean |
|
154 | - */ |
|
155 | - protected function _flagSet(int $flag): bool |
|
156 | - { |
|
157 | - return (bool) ($this->_keyUsage & $flag); |
|
158 | - } |
|
149 | + /** |
|
150 | + * Check whether given flag is set. |
|
151 | + * |
|
152 | + * @param int $flag |
|
153 | + * @return boolean |
|
154 | + */ |
|
155 | + protected function _flagSet(int $flag): bool |
|
156 | + { |
|
157 | + return (bool) ($this->_keyUsage & $flag); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * |
|
162 | - * {@inheritdoc} |
|
163 | - * @return BitString |
|
164 | - */ |
|
165 | - protected function _valueASN1(): BitString |
|
166 | - { |
|
167 | - $flags = new Flags($this->_keyUsage, 9); |
|
168 | - return $flags->bitString()->withoutTrailingZeroes(); |
|
169 | - } |
|
160 | + /** |
|
161 | + * |
|
162 | + * {@inheritdoc} |
|
163 | + * @return BitString |
|
164 | + */ |
|
165 | + protected function _valueASN1(): BitString |
|
166 | + { |
|
167 | + $flags = new Flags($this->_keyUsage, 9); |
|
168 | + return $flags->bitString()->withoutTrailingZeroes(); |
|
169 | + } |
|
170 | 170 | } |
@@ -14,53 +14,53 @@ |
||
14 | 14 | */ |
15 | 15 | class SubjectKeyIdentifierExtension extends Extension |
16 | 16 | { |
17 | - /** |
|
18 | - * Key identifier. |
|
19 | - * |
|
20 | - * @var string $_keyIdentifier |
|
21 | - */ |
|
22 | - protected $_keyIdentifier; |
|
17 | + /** |
|
18 | + * Key identifier. |
|
19 | + * |
|
20 | + * @var string $_keyIdentifier |
|
21 | + */ |
|
22 | + protected $_keyIdentifier; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor. |
|
26 | - * |
|
27 | - * @param bool $critical |
|
28 | - * @param string $keyIdentifier |
|
29 | - */ |
|
30 | - public function __construct(bool $critical, string $keyIdentifier) |
|
31 | - { |
|
32 | - parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
|
33 | - $this->_keyIdentifier = $keyIdentifier; |
|
34 | - } |
|
24 | + /** |
|
25 | + * Constructor. |
|
26 | + * |
|
27 | + * @param bool $critical |
|
28 | + * @param string $keyIdentifier |
|
29 | + */ |
|
30 | + public function __construct(bool $critical, string $keyIdentifier) |
|
31 | + { |
|
32 | + parent::__construct(self::OID_SUBJECT_KEY_IDENTIFIER, $critical); |
|
33 | + $this->_keyIdentifier = $keyIdentifier; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * |
|
38 | - * {@inheritdoc} |
|
39 | - * @return self |
|
40 | - */ |
|
41 | - protected static function _fromDER(string $data, bool $critical): self |
|
42 | - { |
|
43 | - return new self($critical, |
|
44 | - UnspecifiedType::fromDER($data)->asOctetString()->string()); |
|
45 | - } |
|
36 | + /** |
|
37 | + * |
|
38 | + * {@inheritdoc} |
|
39 | + * @return self |
|
40 | + */ |
|
41 | + protected static function _fromDER(string $data, bool $critical): self |
|
42 | + { |
|
43 | + return new self($critical, |
|
44 | + UnspecifiedType::fromDER($data)->asOctetString()->string()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get key identifier. |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function keyIdentifier(): string |
|
53 | - { |
|
54 | - return $this->_keyIdentifier; |
|
55 | - } |
|
47 | + /** |
|
48 | + * Get key identifier. |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function keyIdentifier(): string |
|
53 | + { |
|
54 | + return $this->_keyIdentifier; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * |
|
59 | - * {@inheritdoc} |
|
60 | - * @return OctetString |
|
61 | - */ |
|
62 | - protected function _valueASN1(): OctetString |
|
63 | - { |
|
64 | - return new OctetString($this->_keyIdentifier); |
|
65 | - } |
|
57 | + /** |
|
58 | + * |
|
59 | + * {@inheritdoc} |
|
60 | + * @return OctetString |
|
61 | + */ |
|
62 | + protected function _valueASN1(): OctetString |
|
63 | + { |
|
64 | + return new OctetString($this->_keyIdentifier); |
|
65 | + } |
|
66 | 66 | } |
@@ -14,136 +14,136 @@ |
||
14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.4 |
15 | 15 | */ |
16 | 16 | class CertificatePoliciesExtension extends Extension implements |
17 | - \Countable, |
|
18 | - \IteratorAggregate |
|
17 | + \Countable, |
|
18 | + \IteratorAggregate |
|
19 | 19 | { |
20 | - /** |
|
21 | - * Policy information terms. |
|
22 | - * |
|
23 | - * @var PolicyInformation[] $_policies |
|
24 | - */ |
|
25 | - protected $_policies; |
|
20 | + /** |
|
21 | + * Policy information terms. |
|
22 | + * |
|
23 | + * @var PolicyInformation[] $_policies |
|
24 | + */ |
|
25 | + protected $_policies; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param bool $critical |
|
31 | - * @param PolicyInformation ...$policies |
|
32 | - */ |
|
33 | - public function __construct(bool $critical, PolicyInformation ...$policies) |
|
34 | - { |
|
35 | - parent::__construct(Extension::OID_CERTIFICATE_POLICIES, $critical); |
|
36 | - $this->_policies = []; |
|
37 | - foreach ($policies as $policy) { |
|
38 | - $this->_policies[$policy->oid()] = $policy; |
|
39 | - } |
|
40 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param bool $critical |
|
31 | + * @param PolicyInformation ...$policies |
|
32 | + */ |
|
33 | + public function __construct(bool $critical, PolicyInformation ...$policies) |
|
34 | + { |
|
35 | + parent::__construct(Extension::OID_CERTIFICATE_POLICIES, $critical); |
|
36 | + $this->_policies = []; |
|
37 | + foreach ($policies as $policy) { |
|
38 | + $this->_policies[$policy->oid()] = $policy; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * |
|
44 | - * {@inheritdoc} |
|
45 | - * @return self |
|
46 | - */ |
|
47 | - protected static function _fromDER(string $data, bool $critical): self |
|
48 | - { |
|
49 | - $policies = array_map( |
|
50 | - function (UnspecifiedType $el) { |
|
51 | - return PolicyInformation::fromASN1($el->asSequence()); |
|
52 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
53 | - if (!count($policies)) { |
|
54 | - throw new \UnexpectedValueException( |
|
55 | - "certificatePolicies must contain" . |
|
56 | - " at least one PolicyInformation."); |
|
57 | - } |
|
58 | - return new self($critical, ...$policies); |
|
59 | - } |
|
42 | + /** |
|
43 | + * |
|
44 | + * {@inheritdoc} |
|
45 | + * @return self |
|
46 | + */ |
|
47 | + protected static function _fromDER(string $data, bool $critical): self |
|
48 | + { |
|
49 | + $policies = array_map( |
|
50 | + function (UnspecifiedType $el) { |
|
51 | + return PolicyInformation::fromASN1($el->asSequence()); |
|
52 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
53 | + if (!count($policies)) { |
|
54 | + throw new \UnexpectedValueException( |
|
55 | + "certificatePolicies must contain" . |
|
56 | + " at least one PolicyInformation."); |
|
57 | + } |
|
58 | + return new self($critical, ...$policies); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Check whether policy information by OID is present. |
|
63 | - * |
|
64 | - * @param string $oid |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function has(string $oid): bool |
|
68 | - { |
|
69 | - return isset($this->_policies[$oid]); |
|
70 | - } |
|
61 | + /** |
|
62 | + * Check whether policy information by OID is present. |
|
63 | + * |
|
64 | + * @param string $oid |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function has(string $oid): bool |
|
68 | + { |
|
69 | + return isset($this->_policies[$oid]); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get policy information by OID. |
|
74 | - * |
|
75 | - * @param string $oid |
|
76 | - * @throws \LogicException |
|
77 | - * @return PolicyInformation |
|
78 | - */ |
|
79 | - public function get(string $oid): PolicyInformation |
|
80 | - { |
|
81 | - if (!$this->has($oid)) { |
|
82 | - throw new \LogicException("Not certificate policy by OID $oid."); |
|
83 | - } |
|
84 | - return $this->_policies[$oid]; |
|
85 | - } |
|
72 | + /** |
|
73 | + * Get policy information by OID. |
|
74 | + * |
|
75 | + * @param string $oid |
|
76 | + * @throws \LogicException |
|
77 | + * @return PolicyInformation |
|
78 | + */ |
|
79 | + public function get(string $oid): PolicyInformation |
|
80 | + { |
|
81 | + if (!$this->has($oid)) { |
|
82 | + throw new \LogicException("Not certificate policy by OID $oid."); |
|
83 | + } |
|
84 | + return $this->_policies[$oid]; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Check whether anyPolicy is present. |
|
89 | - * |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function hasAnyPolicy(): bool |
|
93 | - { |
|
94 | - return $this->has(PolicyInformation::OID_ANY_POLICY); |
|
95 | - } |
|
87 | + /** |
|
88 | + * Check whether anyPolicy is present. |
|
89 | + * |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function hasAnyPolicy(): bool |
|
93 | + { |
|
94 | + return $this->has(PolicyInformation::OID_ANY_POLICY); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Get anyPolicy information. |
|
99 | - * |
|
100 | - * @throws \LogicException If anyPolicy is not present. |
|
101 | - * @return PolicyInformation |
|
102 | - */ |
|
103 | - public function anyPolicy(): PolicyInformation |
|
104 | - { |
|
105 | - if (!$this->hasAnyPolicy()) { |
|
106 | - throw new \LogicException("No anyPolicy."); |
|
107 | - } |
|
108 | - return $this->get(PolicyInformation::OID_ANY_POLICY); |
|
109 | - } |
|
97 | + /** |
|
98 | + * Get anyPolicy information. |
|
99 | + * |
|
100 | + * @throws \LogicException If anyPolicy is not present. |
|
101 | + * @return PolicyInformation |
|
102 | + */ |
|
103 | + public function anyPolicy(): PolicyInformation |
|
104 | + { |
|
105 | + if (!$this->hasAnyPolicy()) { |
|
106 | + throw new \LogicException("No anyPolicy."); |
|
107 | + } |
|
108 | + return $this->get(PolicyInformation::OID_ANY_POLICY); |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * |
|
113 | - * {@inheritdoc} |
|
114 | - * @return Sequence |
|
115 | - */ |
|
116 | - protected function _valueASN1(): Sequence |
|
117 | - { |
|
118 | - if (!count($this->_policies)) { |
|
119 | - throw new \LogicException("No policies."); |
|
120 | - } |
|
121 | - $elements = array_map( |
|
122 | - function (PolicyInformation $pi) { |
|
123 | - return $pi->toASN1(); |
|
124 | - }, array_values($this->_policies)); |
|
125 | - return new Sequence(...$elements); |
|
126 | - } |
|
111 | + /** |
|
112 | + * |
|
113 | + * {@inheritdoc} |
|
114 | + * @return Sequence |
|
115 | + */ |
|
116 | + protected function _valueASN1(): Sequence |
|
117 | + { |
|
118 | + if (!count($this->_policies)) { |
|
119 | + throw new \LogicException("No policies."); |
|
120 | + } |
|
121 | + $elements = array_map( |
|
122 | + function (PolicyInformation $pi) { |
|
123 | + return $pi->toASN1(); |
|
124 | + }, array_values($this->_policies)); |
|
125 | + return new Sequence(...$elements); |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Get the number of policies. |
|
130 | - * |
|
131 | - * @see \Countable::count() |
|
132 | - * @return int |
|
133 | - */ |
|
134 | - public function count(): int |
|
135 | - { |
|
136 | - return count($this->_policies); |
|
137 | - } |
|
128 | + /** |
|
129 | + * Get the number of policies. |
|
130 | + * |
|
131 | + * @see \Countable::count() |
|
132 | + * @return int |
|
133 | + */ |
|
134 | + public function count(): int |
|
135 | + { |
|
136 | + return count($this->_policies); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Get iterator for policy information terms. |
|
141 | - * |
|
142 | - * @see \IteratorAggregate::getIterator() |
|
143 | - * @return \ArrayIterator |
|
144 | - */ |
|
145 | - public function getIterator(): \ArrayIterator |
|
146 | - { |
|
147 | - return new \ArrayIterator($this->_policies); |
|
148 | - } |
|
139 | + /** |
|
140 | + * Get iterator for policy information terms. |
|
141 | + * |
|
142 | + * @see \IteratorAggregate::getIterator() |
|
143 | + * @return \ArrayIterator |
|
144 | + */ |
|
145 | + public function getIterator(): \ArrayIterator |
|
146 | + { |
|
147 | + return new \ArrayIterator($this->_policies); |
|
148 | + } |
|
149 | 149 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | protected static function _fromDER(string $data, bool $critical): self |
48 | 48 | { |
49 | 49 | $policies = array_map( |
50 | - function (UnspecifiedType $el) { |
|
50 | + function(UnspecifiedType $el) { |
|
51 | 51 | return PolicyInformation::fromASN1($el->asSequence()); |
52 | 52 | }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
53 | 53 | if (!count($policies)) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | throw new \LogicException("No policies."); |
120 | 120 | } |
121 | 121 | $elements = array_map( |
122 | - function (PolicyInformation $pi) { |
|
122 | + function(PolicyInformation $pi) { |
|
123 | 123 | return $pi->toASN1(); |
124 | 124 | }, array_values($this->_policies)); |
125 | 125 | return new Sequence(...$elements); |
@@ -17,125 +17,125 @@ |
||
17 | 17 | */ |
18 | 18 | class PolicyConstraintsExtension extends Extension |
19 | 19 | { |
20 | - /** |
|
21 | - * |
|
22 | - * @var int $_requireExplicitPolicy |
|
23 | - */ |
|
24 | - protected $_requireExplicitPolicy; |
|
20 | + /** |
|
21 | + * |
|
22 | + * @var int $_requireExplicitPolicy |
|
23 | + */ |
|
24 | + protected $_requireExplicitPolicy; |
|
25 | 25 | |
26 | - /** |
|
27 | - * |
|
28 | - * @var int $_inhibitPolicyMapping |
|
29 | - */ |
|
30 | - protected $_inhibitPolicyMapping; |
|
26 | + /** |
|
27 | + * |
|
28 | + * @var int $_inhibitPolicyMapping |
|
29 | + */ |
|
30 | + protected $_inhibitPolicyMapping; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Constructor. |
|
34 | - * |
|
35 | - * @param bool $critical |
|
36 | - * @param int|null $require_explicit_policy |
|
37 | - * @param int|null $inhibit_policy_mapping |
|
38 | - */ |
|
39 | - public function __construct(bool $critical, $require_explicit_policy = null, |
|
40 | - $inhibit_policy_mapping = null) |
|
41 | - { |
|
42 | - parent::__construct(self::OID_POLICY_CONSTRAINTS, $critical); |
|
43 | - $this->_requireExplicitPolicy = isset($require_explicit_policy) ? intval( |
|
44 | - $require_explicit_policy) : null; |
|
45 | - $this->_inhibitPolicyMapping = isset($inhibit_policy_mapping) ? intval( |
|
46 | - $inhibit_policy_mapping) : null; |
|
47 | - } |
|
32 | + /** |
|
33 | + * Constructor. |
|
34 | + * |
|
35 | + * @param bool $critical |
|
36 | + * @param int|null $require_explicit_policy |
|
37 | + * @param int|null $inhibit_policy_mapping |
|
38 | + */ |
|
39 | + public function __construct(bool $critical, $require_explicit_policy = null, |
|
40 | + $inhibit_policy_mapping = null) |
|
41 | + { |
|
42 | + parent::__construct(self::OID_POLICY_CONSTRAINTS, $critical); |
|
43 | + $this->_requireExplicitPolicy = isset($require_explicit_policy) ? intval( |
|
44 | + $require_explicit_policy) : null; |
|
45 | + $this->_inhibitPolicyMapping = isset($inhibit_policy_mapping) ? intval( |
|
46 | + $inhibit_policy_mapping) : null; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * {@inheritdoc} |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - protected static function _fromDER(string $data, bool $critical): self |
|
55 | - { |
|
56 | - $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
57 | - $require_explicit_policy = null; |
|
58 | - $inhibit_policy_mapping = null; |
|
59 | - if ($seq->hasTagged(0)) { |
|
60 | - $require_explicit_policy = $seq->getTagged(0) |
|
61 | - ->asImplicit(Element::TYPE_INTEGER) |
|
62 | - ->asInteger() |
|
63 | - ->intNumber(); |
|
64 | - } |
|
65 | - if ($seq->hasTagged(1)) { |
|
66 | - $inhibit_policy_mapping = $seq->getTagged(1) |
|
67 | - ->asImplicit(Element::TYPE_INTEGER) |
|
68 | - ->asInteger() |
|
69 | - ->intNumber(); |
|
70 | - } |
|
71 | - return new self($critical, $require_explicit_policy, |
|
72 | - $inhibit_policy_mapping); |
|
73 | - } |
|
49 | + /** |
|
50 | + * |
|
51 | + * {@inheritdoc} |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + protected static function _fromDER(string $data, bool $critical): self |
|
55 | + { |
|
56 | + $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
57 | + $require_explicit_policy = null; |
|
58 | + $inhibit_policy_mapping = null; |
|
59 | + if ($seq->hasTagged(0)) { |
|
60 | + $require_explicit_policy = $seq->getTagged(0) |
|
61 | + ->asImplicit(Element::TYPE_INTEGER) |
|
62 | + ->asInteger() |
|
63 | + ->intNumber(); |
|
64 | + } |
|
65 | + if ($seq->hasTagged(1)) { |
|
66 | + $inhibit_policy_mapping = $seq->getTagged(1) |
|
67 | + ->asImplicit(Element::TYPE_INTEGER) |
|
68 | + ->asInteger() |
|
69 | + ->intNumber(); |
|
70 | + } |
|
71 | + return new self($critical, $require_explicit_policy, |
|
72 | + $inhibit_policy_mapping); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Whether requireExplicitPolicy is present. |
|
77 | - * |
|
78 | - * @return bool |
|
79 | - */ |
|
80 | - public function hasRequireExplicitPolicy(): bool |
|
81 | - { |
|
82 | - return isset($this->_requireExplicitPolicy); |
|
83 | - } |
|
75 | + /** |
|
76 | + * Whether requireExplicitPolicy is present. |
|
77 | + * |
|
78 | + * @return bool |
|
79 | + */ |
|
80 | + public function hasRequireExplicitPolicy(): bool |
|
81 | + { |
|
82 | + return isset($this->_requireExplicitPolicy); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Get requireExplicitPolicy. |
|
87 | - * |
|
88 | - * @throws \LogicException |
|
89 | - * @return int |
|
90 | - */ |
|
91 | - public function requireExplicitPolicy(): int |
|
92 | - { |
|
93 | - if (!$this->hasRequireExplicitPolicy()) { |
|
94 | - throw new \LogicException("requireExplicitPolicy not set."); |
|
95 | - } |
|
96 | - return $this->_requireExplicitPolicy; |
|
97 | - } |
|
85 | + /** |
|
86 | + * Get requireExplicitPolicy. |
|
87 | + * |
|
88 | + * @throws \LogicException |
|
89 | + * @return int |
|
90 | + */ |
|
91 | + public function requireExplicitPolicy(): int |
|
92 | + { |
|
93 | + if (!$this->hasRequireExplicitPolicy()) { |
|
94 | + throw new \LogicException("requireExplicitPolicy not set."); |
|
95 | + } |
|
96 | + return $this->_requireExplicitPolicy; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Whether inhibitPolicyMapping is present. |
|
101 | - * |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - public function hasInhibitPolicyMapping(): bool |
|
105 | - { |
|
106 | - return isset($this->_inhibitPolicyMapping); |
|
107 | - } |
|
99 | + /** |
|
100 | + * Whether inhibitPolicyMapping is present. |
|
101 | + * |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + public function hasInhibitPolicyMapping(): bool |
|
105 | + { |
|
106 | + return isset($this->_inhibitPolicyMapping); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Get inhibitPolicyMapping. |
|
111 | - * |
|
112 | - * @throws \LogicException |
|
113 | - * @return int |
|
114 | - */ |
|
115 | - public function inhibitPolicyMapping(): int |
|
116 | - { |
|
117 | - if (!$this->hasInhibitPolicyMapping()) { |
|
118 | - throw new \LogicException("inhibitPolicyMapping not set."); |
|
119 | - } |
|
120 | - return $this->_inhibitPolicyMapping; |
|
121 | - } |
|
109 | + /** |
|
110 | + * Get inhibitPolicyMapping. |
|
111 | + * |
|
112 | + * @throws \LogicException |
|
113 | + * @return int |
|
114 | + */ |
|
115 | + public function inhibitPolicyMapping(): int |
|
116 | + { |
|
117 | + if (!$this->hasInhibitPolicyMapping()) { |
|
118 | + throw new \LogicException("inhibitPolicyMapping not set."); |
|
119 | + } |
|
120 | + return $this->_inhibitPolicyMapping; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * |
|
125 | - * {@inheritdoc} |
|
126 | - * @return Sequence |
|
127 | - */ |
|
128 | - protected function _valueASN1(): Sequence |
|
129 | - { |
|
130 | - $elements = array(); |
|
131 | - if (isset($this->_requireExplicitPolicy)) { |
|
132 | - $elements[] = new ImplicitlyTaggedType(0, |
|
133 | - new Integer($this->_requireExplicitPolicy)); |
|
134 | - } |
|
135 | - if (isset($this->_inhibitPolicyMapping)) { |
|
136 | - $elements[] = new ImplicitlyTaggedType(1, |
|
137 | - new Integer($this->_inhibitPolicyMapping)); |
|
138 | - } |
|
139 | - return new Sequence(...$elements); |
|
140 | - } |
|
123 | + /** |
|
124 | + * |
|
125 | + * {@inheritdoc} |
|
126 | + * @return Sequence |
|
127 | + */ |
|
128 | + protected function _valueASN1(): Sequence |
|
129 | + { |
|
130 | + $elements = array(); |
|
131 | + if (isset($this->_requireExplicitPolicy)) { |
|
132 | + $elements[] = new ImplicitlyTaggedType(0, |
|
133 | + new Integer($this->_requireExplicitPolicy)); |
|
134 | + } |
|
135 | + if (isset($this->_inhibitPolicyMapping)) { |
|
136 | + $elements[] = new ImplicitlyTaggedType(1, |
|
137 | + new Integer($this->_inhibitPolicyMapping)); |
|
138 | + } |
|
139 | + return new Sequence(...$elements); |
|
140 | + } |
|
141 | 141 | } |
@@ -14,95 +14,95 @@ |
||
14 | 14 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.13 |
15 | 15 | */ |
16 | 16 | class CRLDistributionPointsExtension extends Extension implements |
17 | - \Countable, |
|
18 | - \IteratorAggregate |
|
17 | + \Countable, |
|
18 | + \IteratorAggregate |
|
19 | 19 | { |
20 | - /** |
|
21 | - * Distribution points. |
|
22 | - * |
|
23 | - * @var DistributionPoint[] $_distributionPoints |
|
24 | - */ |
|
25 | - protected $_distributionPoints; |
|
20 | + /** |
|
21 | + * Distribution points. |
|
22 | + * |
|
23 | + * @var DistributionPoint[] $_distributionPoints |
|
24 | + */ |
|
25 | + protected $_distributionPoints; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param bool $critical |
|
31 | - * @param DistributionPoint ...$distribution_points |
|
32 | - */ |
|
33 | - public function __construct(bool $critical, |
|
34 | - DistributionPoint ...$distribution_points) |
|
35 | - { |
|
36 | - parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
37 | - $this->_distributionPoints = $distribution_points; |
|
38 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param bool $critical |
|
31 | + * @param DistributionPoint ...$distribution_points |
|
32 | + */ |
|
33 | + public function __construct(bool $critical, |
|
34 | + DistributionPoint ...$distribution_points) |
|
35 | + { |
|
36 | + parent::__construct(self::OID_CRL_DISTRIBUTION_POINTS, $critical); |
|
37 | + $this->_distributionPoints = $distribution_points; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * |
|
42 | - * {@inheritdoc} |
|
43 | - * @return self |
|
44 | - */ |
|
45 | - protected static function _fromDER(string $data, bool $critical): self |
|
46 | - { |
|
47 | - $dps = array_map( |
|
48 | - function (UnspecifiedType $el) { |
|
49 | - return DistributionPoint::fromASN1($el->asSequence()); |
|
50 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
51 | - if (!count($dps)) { |
|
52 | - throw new \UnexpectedValueException( |
|
53 | - "CRLDistributionPoints must have" . |
|
54 | - " at least one DistributionPoint."); |
|
55 | - } |
|
56 | - // late static bound, extended by Freshest CRL extension |
|
57 | - return new static($critical, ...$dps); |
|
58 | - } |
|
40 | + /** |
|
41 | + * |
|
42 | + * {@inheritdoc} |
|
43 | + * @return self |
|
44 | + */ |
|
45 | + protected static function _fromDER(string $data, bool $critical): self |
|
46 | + { |
|
47 | + $dps = array_map( |
|
48 | + function (UnspecifiedType $el) { |
|
49 | + return DistributionPoint::fromASN1($el->asSequence()); |
|
50 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
51 | + if (!count($dps)) { |
|
52 | + throw new \UnexpectedValueException( |
|
53 | + "CRLDistributionPoints must have" . |
|
54 | + " at least one DistributionPoint."); |
|
55 | + } |
|
56 | + // late static bound, extended by Freshest CRL extension |
|
57 | + return new static($critical, ...$dps); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * |
|
62 | - * {@inheritdoc} |
|
63 | - * @return Sequence |
|
64 | - */ |
|
65 | - protected function _valueASN1(): Sequence |
|
66 | - { |
|
67 | - if (!count($this->_distributionPoints)) { |
|
68 | - throw new \LogicException("No distribution points."); |
|
69 | - } |
|
70 | - $elements = array_map( |
|
71 | - function (DistributionPoint $dp) { |
|
72 | - return $dp->toASN1(); |
|
73 | - }, $this->_distributionPoints); |
|
74 | - return new Sequence(...$elements); |
|
75 | - } |
|
60 | + /** |
|
61 | + * |
|
62 | + * {@inheritdoc} |
|
63 | + * @return Sequence |
|
64 | + */ |
|
65 | + protected function _valueASN1(): Sequence |
|
66 | + { |
|
67 | + if (!count($this->_distributionPoints)) { |
|
68 | + throw new \LogicException("No distribution points."); |
|
69 | + } |
|
70 | + $elements = array_map( |
|
71 | + function (DistributionPoint $dp) { |
|
72 | + return $dp->toASN1(); |
|
73 | + }, $this->_distributionPoints); |
|
74 | + return new Sequence(...$elements); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Get distribution points. |
|
79 | - * |
|
80 | - * @return DistributionPoint[] |
|
81 | - */ |
|
82 | - public function distributionPoints(): array |
|
83 | - { |
|
84 | - return $this->_distributionPoints; |
|
85 | - } |
|
77 | + /** |
|
78 | + * Get distribution points. |
|
79 | + * |
|
80 | + * @return DistributionPoint[] |
|
81 | + */ |
|
82 | + public function distributionPoints(): array |
|
83 | + { |
|
84 | + return $this->_distributionPoints; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Get the number of distribution points. |
|
89 | - * |
|
90 | - * @see \Countable::count() |
|
91 | - * @return int |
|
92 | - */ |
|
93 | - public function count(): int |
|
94 | - { |
|
95 | - return count($this->_distributionPoints); |
|
96 | - } |
|
87 | + /** |
|
88 | + * Get the number of distribution points. |
|
89 | + * |
|
90 | + * @see \Countable::count() |
|
91 | + * @return int |
|
92 | + */ |
|
93 | + public function count(): int |
|
94 | + { |
|
95 | + return count($this->_distributionPoints); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Get iterator for distribution points. |
|
100 | - * |
|
101 | - * @see \IteratorAggregate::getIterator() |
|
102 | - * @return \ArrayIterator |
|
103 | - */ |
|
104 | - public function getIterator(): \ArrayIterator |
|
105 | - { |
|
106 | - return new \ArrayIterator($this->_distributionPoints); |
|
107 | - } |
|
98 | + /** |
|
99 | + * Get iterator for distribution points. |
|
100 | + * |
|
101 | + * @see \IteratorAggregate::getIterator() |
|
102 | + * @return \ArrayIterator |
|
103 | + */ |
|
104 | + public function getIterator(): \ArrayIterator |
|
105 | + { |
|
106 | + return new \ArrayIterator($this->_distributionPoints); |
|
107 | + } |
|
108 | 108 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | protected static function _fromDER(string $data, bool $critical): self |
46 | 46 | { |
47 | 47 | $dps = array_map( |
48 | - function (UnspecifiedType $el) { |
|
48 | + function(UnspecifiedType $el) { |
|
49 | 49 | return DistributionPoint::fromASN1($el->asSequence()); |
50 | 50 | }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
51 | 51 | if (!count($dps)) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | throw new \LogicException("No distribution points."); |
69 | 69 | } |
70 | 70 | $elements = array_map( |
71 | - function (DistributionPoint $dp) { |
|
71 | + function(DistributionPoint $dp) { |
|
72 | 72 | return $dp->toASN1(); |
73 | 73 | }, $this->_distributionPoints); |
74 | 74 | return new Sequence(...$elements); |
@@ -17,106 +17,106 @@ |
||
17 | 17 | */ |
18 | 18 | class BasicConstraintsExtension extends Extension |
19 | 19 | { |
20 | - /** |
|
21 | - * Whether certificate is a CA. |
|
22 | - * |
|
23 | - * @var boolean $_ca |
|
24 | - */ |
|
25 | - protected $_ca; |
|
20 | + /** |
|
21 | + * Whether certificate is a CA. |
|
22 | + * |
|
23 | + * @var boolean $_ca |
|
24 | + */ |
|
25 | + protected $_ca; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Maximum certification path length. |
|
29 | - * |
|
30 | - * @var int|null $_pathLen |
|
31 | - */ |
|
32 | - protected $_pathLen; |
|
27 | + /** |
|
28 | + * Maximum certification path length. |
|
29 | + * |
|
30 | + * @var int|null $_pathLen |
|
31 | + */ |
|
32 | + protected $_pathLen; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor. |
|
36 | - * |
|
37 | - * @param bool $critical |
|
38 | - * @param bool $ca |
|
39 | - * @param int|null $path_len |
|
40 | - */ |
|
41 | - public function __construct(bool $critical, bool $ca, $path_len = null) |
|
42 | - { |
|
43 | - parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical); |
|
44 | - $this->_ca = $ca; |
|
45 | - $this->_pathLen = isset($path_len) ? intval($path_len) : null; |
|
46 | - } |
|
34 | + /** |
|
35 | + * Constructor. |
|
36 | + * |
|
37 | + * @param bool $critical |
|
38 | + * @param bool $ca |
|
39 | + * @param int|null $path_len |
|
40 | + */ |
|
41 | + public function __construct(bool $critical, bool $ca, $path_len = null) |
|
42 | + { |
|
43 | + parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical); |
|
44 | + $this->_ca = $ca; |
|
45 | + $this->_pathLen = isset($path_len) ? intval($path_len) : null; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * |
|
50 | - * {@inheritdoc} |
|
51 | - * @return self |
|
52 | - */ |
|
53 | - protected static function _fromDER(string $data, bool $critical): self |
|
54 | - { |
|
55 | - $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
56 | - $ca = false; |
|
57 | - $path_len = null; |
|
58 | - $idx = 0; |
|
59 | - if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
60 | - $ca = $seq->at($idx++) |
|
61 | - ->asBoolean() |
|
62 | - ->value(); |
|
63 | - } |
|
64 | - if ($seq->has($idx, Element::TYPE_INTEGER)) { |
|
65 | - $path_len = $seq->at($idx) |
|
66 | - ->asInteger() |
|
67 | - ->intNumber(); |
|
68 | - } |
|
69 | - return new self($critical, $ca, $path_len); |
|
70 | - } |
|
48 | + /** |
|
49 | + * |
|
50 | + * {@inheritdoc} |
|
51 | + * @return self |
|
52 | + */ |
|
53 | + protected static function _fromDER(string $data, bool $critical): self |
|
54 | + { |
|
55 | + $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
56 | + $ca = false; |
|
57 | + $path_len = null; |
|
58 | + $idx = 0; |
|
59 | + if ($seq->has($idx, Element::TYPE_BOOLEAN)) { |
|
60 | + $ca = $seq->at($idx++) |
|
61 | + ->asBoolean() |
|
62 | + ->value(); |
|
63 | + } |
|
64 | + if ($seq->has($idx, Element::TYPE_INTEGER)) { |
|
65 | + $path_len = $seq->at($idx) |
|
66 | + ->asInteger() |
|
67 | + ->intNumber(); |
|
68 | + } |
|
69 | + return new self($critical, $ca, $path_len); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Whether certificate is a CA. |
|
74 | - * |
|
75 | - * @return bool |
|
76 | - */ |
|
77 | - public function isCA(): bool |
|
78 | - { |
|
79 | - return $this->_ca; |
|
80 | - } |
|
72 | + /** |
|
73 | + * Whether certificate is a CA. |
|
74 | + * |
|
75 | + * @return bool |
|
76 | + */ |
|
77 | + public function isCA(): bool |
|
78 | + { |
|
79 | + return $this->_ca; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Whether path length is present. |
|
84 | - * |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function hasPathLen(): bool |
|
88 | - { |
|
89 | - return isset($this->_pathLen); |
|
90 | - } |
|
82 | + /** |
|
83 | + * Whether path length is present. |
|
84 | + * |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function hasPathLen(): bool |
|
88 | + { |
|
89 | + return isset($this->_pathLen); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Get path length. |
|
94 | - * |
|
95 | - * @throws \LogicException |
|
96 | - * @return int |
|
97 | - */ |
|
98 | - public function pathLen(): int |
|
99 | - { |
|
100 | - if (!$this->hasPathLen()) { |
|
101 | - throw new \LogicException("pathLenConstraint not set."); |
|
102 | - } |
|
103 | - return $this->_pathLen; |
|
104 | - } |
|
92 | + /** |
|
93 | + * Get path length. |
|
94 | + * |
|
95 | + * @throws \LogicException |
|
96 | + * @return int |
|
97 | + */ |
|
98 | + public function pathLen(): int |
|
99 | + { |
|
100 | + if (!$this->hasPathLen()) { |
|
101 | + throw new \LogicException("pathLenConstraint not set."); |
|
102 | + } |
|
103 | + return $this->_pathLen; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * |
|
108 | - * {@inheritdoc} |
|
109 | - * @return Sequence |
|
110 | - */ |
|
111 | - protected function _valueASN1(): Sequence |
|
112 | - { |
|
113 | - $elements = array(); |
|
114 | - if ($this->_ca) { |
|
115 | - $elements[] = new Boolean(true); |
|
116 | - } |
|
117 | - if (isset($this->_pathLen)) { |
|
118 | - $elements[] = new Integer($this->_pathLen); |
|
119 | - } |
|
120 | - return new Sequence(...$elements); |
|
121 | - } |
|
106 | + /** |
|
107 | + * |
|
108 | + * {@inheritdoc} |
|
109 | + * @return Sequence |
|
110 | + */ |
|
111 | + protected function _valueASN1(): Sequence |
|
112 | + { |
|
113 | + $elements = array(); |
|
114 | + if ($this->_ca) { |
|
115 | + $elements[] = new Boolean(true); |
|
116 | + } |
|
117 | + if (isset($this->_pathLen)) { |
|
118 | + $elements[] = new Integer($this->_pathLen); |
|
119 | + } |
|
120 | + return new Sequence(...$elements); |
|
121 | + } |
|
122 | 122 | } |
@@ -15,55 +15,55 @@ |
||
15 | 15 | * @link https://tools.ietf.org/html/rfc5280#section-4.2.1.8 |
16 | 16 | */ |
17 | 17 | class SubjectDirectoryAttributesExtension extends Extension implements |
18 | - \Countable, |
|
19 | - \IteratorAggregate |
|
18 | + \Countable, |
|
19 | + \IteratorAggregate |
|
20 | 20 | { |
21 | - use AttributeContainer; |
|
21 | + use AttributeContainer; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor. |
|
25 | - * |
|
26 | - * @param bool $critical |
|
27 | - * @param Attribute ...$attribs One or more Attribute objects |
|
28 | - */ |
|
29 | - public function __construct(bool $critical, Attribute ...$attribs) |
|
30 | - { |
|
31 | - parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
32 | - $this->_attributes = $attribs; |
|
33 | - } |
|
23 | + /** |
|
24 | + * Constructor. |
|
25 | + * |
|
26 | + * @param bool $critical |
|
27 | + * @param Attribute ...$attribs One or more Attribute objects |
|
28 | + */ |
|
29 | + public function __construct(bool $critical, Attribute ...$attribs) |
|
30 | + { |
|
31 | + parent::__construct(self::OID_SUBJECT_DIRECTORY_ATTRIBUTES, $critical); |
|
32 | + $this->_attributes = $attribs; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * |
|
37 | - * {@inheritdoc} |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - protected static function _fromDER(string $data, bool $critical): self |
|
41 | - { |
|
42 | - $attribs = array_map( |
|
43 | - function (UnspecifiedType $el) { |
|
44 | - return Attribute::fromASN1($el->asSequence()); |
|
45 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
46 | - if (!count($attribs)) { |
|
47 | - throw new \UnexpectedValueException( |
|
48 | - "SubjectDirectoryAttributes must have at least one Attribute."); |
|
49 | - } |
|
50 | - return new self($critical, ...$attribs); |
|
51 | - } |
|
35 | + /** |
|
36 | + * |
|
37 | + * {@inheritdoc} |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + protected static function _fromDER(string $data, bool $critical): self |
|
41 | + { |
|
42 | + $attribs = array_map( |
|
43 | + function (UnspecifiedType $el) { |
|
44 | + return Attribute::fromASN1($el->asSequence()); |
|
45 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
46 | + if (!count($attribs)) { |
|
47 | + throw new \UnexpectedValueException( |
|
48 | + "SubjectDirectoryAttributes must have at least one Attribute."); |
|
49 | + } |
|
50 | + return new self($critical, ...$attribs); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * |
|
55 | - * {@inheritdoc} |
|
56 | - * @return Sequence |
|
57 | - */ |
|
58 | - protected function _valueASN1(): Sequence |
|
59 | - { |
|
60 | - if (!count($this->_attributes)) { |
|
61 | - throw new \LogicException("No attributes"); |
|
62 | - } |
|
63 | - $elements = array_map( |
|
64 | - function (Attribute $attr) { |
|
65 | - return $attr->toASN1(); |
|
66 | - }, array_values($this->_attributes)); |
|
67 | - return new Sequence(...$elements); |
|
68 | - } |
|
53 | + /** |
|
54 | + * |
|
55 | + * {@inheritdoc} |
|
56 | + * @return Sequence |
|
57 | + */ |
|
58 | + protected function _valueASN1(): Sequence |
|
59 | + { |
|
60 | + if (!count($this->_attributes)) { |
|
61 | + throw new \LogicException("No attributes"); |
|
62 | + } |
|
63 | + $elements = array_map( |
|
64 | + function (Attribute $attr) { |
|
65 | + return $attr->toASN1(); |
|
66 | + }, array_values($this->_attributes)); |
|
67 | + return new Sequence(...$elements); |
|
68 | + } |
|
69 | 69 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | protected static function _fromDER(string $data, bool $critical): self |
41 | 41 | { |
42 | 42 | $attribs = array_map( |
43 | - function (UnspecifiedType $el) { |
|
43 | + function(UnspecifiedType $el) { |
|
44 | 44 | return Attribute::fromASN1($el->asSequence()); |
45 | 45 | }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
46 | 46 | if (!count($attribs)) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | throw new \LogicException("No attributes"); |
62 | 62 | } |
63 | 63 | $elements = array_map( |
64 | - function (Attribute $attr) { |
|
64 | + function(Attribute $attr) { |
|
65 | 65 | return $attr->toASN1(); |
66 | 66 | }, array_values($this->_attributes)); |
67 | 67 | return new Sequence(...$elements); |
@@ -17,122 +17,122 @@ |
||
17 | 17 | */ |
18 | 18 | class NameConstraintsExtension extends Extension |
19 | 19 | { |
20 | - /** |
|
21 | - * Permitted subtrees. |
|
22 | - * |
|
23 | - * @var GeneralSubtrees|null $_permitted |
|
24 | - */ |
|
25 | - protected $_permitted; |
|
20 | + /** |
|
21 | + * Permitted subtrees. |
|
22 | + * |
|
23 | + * @var GeneralSubtrees|null $_permitted |
|
24 | + */ |
|
25 | + protected $_permitted; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Excluded subtrees. |
|
29 | - * |
|
30 | - * @var GeneralSubtrees|null $_excluded |
|
31 | - */ |
|
32 | - protected $_excluded; |
|
27 | + /** |
|
28 | + * Excluded subtrees. |
|
29 | + * |
|
30 | + * @var GeneralSubtrees|null $_excluded |
|
31 | + */ |
|
32 | + protected $_excluded; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor. |
|
36 | - * |
|
37 | - * @param bool $critical |
|
38 | - * @param GeneralSubtrees $permitted |
|
39 | - * @param GeneralSubtrees $excluded |
|
40 | - */ |
|
41 | - public function __construct(bool $critical, GeneralSubtrees $permitted = null, |
|
42 | - GeneralSubtrees $excluded = null) |
|
43 | - { |
|
44 | - parent::__construct(self::OID_NAME_CONSTRAINTS, $critical); |
|
45 | - $this->_permitted = $permitted; |
|
46 | - $this->_excluded = $excluded; |
|
47 | - } |
|
34 | + /** |
|
35 | + * Constructor. |
|
36 | + * |
|
37 | + * @param bool $critical |
|
38 | + * @param GeneralSubtrees $permitted |
|
39 | + * @param GeneralSubtrees $excluded |
|
40 | + */ |
|
41 | + public function __construct(bool $critical, GeneralSubtrees $permitted = null, |
|
42 | + GeneralSubtrees $excluded = null) |
|
43 | + { |
|
44 | + parent::__construct(self::OID_NAME_CONSTRAINTS, $critical); |
|
45 | + $this->_permitted = $permitted; |
|
46 | + $this->_excluded = $excluded; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * {@inheritdoc} |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - protected static function _fromDER(string $data, bool $critical): self |
|
55 | - { |
|
56 | - $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
57 | - $permitted = null; |
|
58 | - $excluded = null; |
|
59 | - if ($seq->hasTagged(0)) { |
|
60 | - $permitted = GeneralSubtrees::fromASN1( |
|
61 | - $seq->getTagged(0) |
|
62 | - ->asImplicit(Element::TYPE_SEQUENCE) |
|
63 | - ->asSequence()); |
|
64 | - } |
|
65 | - if ($seq->hasTagged(1)) { |
|
66 | - $excluded = GeneralSubtrees::fromASN1( |
|
67 | - $seq->getTagged(1) |
|
68 | - ->asImplicit(Element::TYPE_SEQUENCE) |
|
69 | - ->asSequence()); |
|
70 | - } |
|
71 | - return new self($critical, $permitted, $excluded); |
|
72 | - } |
|
49 | + /** |
|
50 | + * |
|
51 | + * {@inheritdoc} |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + protected static function _fromDER(string $data, bool $critical): self |
|
55 | + { |
|
56 | + $seq = UnspecifiedType::fromDER($data)->asSequence(); |
|
57 | + $permitted = null; |
|
58 | + $excluded = null; |
|
59 | + if ($seq->hasTagged(0)) { |
|
60 | + $permitted = GeneralSubtrees::fromASN1( |
|
61 | + $seq->getTagged(0) |
|
62 | + ->asImplicit(Element::TYPE_SEQUENCE) |
|
63 | + ->asSequence()); |
|
64 | + } |
|
65 | + if ($seq->hasTagged(1)) { |
|
66 | + $excluded = GeneralSubtrees::fromASN1( |
|
67 | + $seq->getTagged(1) |
|
68 | + ->asImplicit(Element::TYPE_SEQUENCE) |
|
69 | + ->asSequence()); |
|
70 | + } |
|
71 | + return new self($critical, $permitted, $excluded); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Whether permitted subtrees are present. |
|
76 | - * |
|
77 | - * @return bool |
|
78 | - */ |
|
79 | - public function hasPermittedSubtrees(): bool |
|
80 | - { |
|
81 | - return isset($this->_permitted); |
|
82 | - } |
|
74 | + /** |
|
75 | + * Whether permitted subtrees are present. |
|
76 | + * |
|
77 | + * @return bool |
|
78 | + */ |
|
79 | + public function hasPermittedSubtrees(): bool |
|
80 | + { |
|
81 | + return isset($this->_permitted); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Get permitted subtrees. |
|
86 | - * |
|
87 | - * @throws \LogicException |
|
88 | - * @return GeneralSubtrees |
|
89 | - */ |
|
90 | - public function permittedSubtrees(): GeneralSubtrees |
|
91 | - { |
|
92 | - if (!$this->hasPermittedSubtrees()) { |
|
93 | - throw new \LogicException("No permitted subtrees."); |
|
94 | - } |
|
95 | - return $this->_permitted; |
|
96 | - } |
|
84 | + /** |
|
85 | + * Get permitted subtrees. |
|
86 | + * |
|
87 | + * @throws \LogicException |
|
88 | + * @return GeneralSubtrees |
|
89 | + */ |
|
90 | + public function permittedSubtrees(): GeneralSubtrees |
|
91 | + { |
|
92 | + if (!$this->hasPermittedSubtrees()) { |
|
93 | + throw new \LogicException("No permitted subtrees."); |
|
94 | + } |
|
95 | + return $this->_permitted; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Whether excluded subtrees are present. |
|
100 | - * |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - public function hasExcludedSubtrees(): bool |
|
104 | - { |
|
105 | - return isset($this->_excluded); |
|
106 | - } |
|
98 | + /** |
|
99 | + * Whether excluded subtrees are present. |
|
100 | + * |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + public function hasExcludedSubtrees(): bool |
|
104 | + { |
|
105 | + return isset($this->_excluded); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Get excluded subtrees. |
|
110 | - * |
|
111 | - * @throws \LogicException |
|
112 | - * @return GeneralSubtrees |
|
113 | - */ |
|
114 | - public function excludedSubtrees(): GeneralSubtrees |
|
115 | - { |
|
116 | - if (!$this->hasExcludedSubtrees()) { |
|
117 | - throw new \LogicException("No excluded subtrees."); |
|
118 | - } |
|
119 | - return $this->_excluded; |
|
120 | - } |
|
108 | + /** |
|
109 | + * Get excluded subtrees. |
|
110 | + * |
|
111 | + * @throws \LogicException |
|
112 | + * @return GeneralSubtrees |
|
113 | + */ |
|
114 | + public function excludedSubtrees(): GeneralSubtrees |
|
115 | + { |
|
116 | + if (!$this->hasExcludedSubtrees()) { |
|
117 | + throw new \LogicException("No excluded subtrees."); |
|
118 | + } |
|
119 | + return $this->_excluded; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * |
|
124 | - * {@inheritdoc} |
|
125 | - * @return Sequence |
|
126 | - */ |
|
127 | - protected function _valueASN1(): Sequence |
|
128 | - { |
|
129 | - $elements = array(); |
|
130 | - if (isset($this->_permitted)) { |
|
131 | - $elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1()); |
|
132 | - } |
|
133 | - if (isset($this->_excluded)) { |
|
134 | - $elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1()); |
|
135 | - } |
|
136 | - return new Sequence(...$elements); |
|
137 | - } |
|
122 | + /** |
|
123 | + * |
|
124 | + * {@inheritdoc} |
|
125 | + * @return Sequence |
|
126 | + */ |
|
127 | + protected function _valueASN1(): Sequence |
|
128 | + { |
|
129 | + $elements = array(); |
|
130 | + if (isset($this->_permitted)) { |
|
131 | + $elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1()); |
|
132 | + } |
|
133 | + if (isset($this->_excluded)) { |
|
134 | + $elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1()); |
|
135 | + } |
|
136 | + return new Sequence(...$elements); |
|
137 | + } |
|
138 | 138 | } |
@@ -19,139 +19,139 @@ |
||
19 | 19 | * @link https://tools.ietf.org/html/rfc5755#section-4.3.2 |
20 | 20 | */ |
21 | 21 | class TargetInformationExtension extends Extension implements |
22 | - \Countable, |
|
23 | - \IteratorAggregate |
|
22 | + \Countable, |
|
23 | + \IteratorAggregate |
|
24 | 24 | { |
25 | - /** |
|
26 | - * Targets elements. |
|
27 | - * |
|
28 | - * @var Targets[] $_targets |
|
29 | - */ |
|
30 | - protected $_targets; |
|
25 | + /** |
|
26 | + * Targets elements. |
|
27 | + * |
|
28 | + * @var Targets[] $_targets |
|
29 | + */ |
|
30 | + protected $_targets; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Targets[] merged to single Targets. |
|
34 | - * |
|
35 | - * @var Targets|null |
|
36 | - */ |
|
37 | - private $_merged; |
|
32 | + /** |
|
33 | + * Targets[] merged to single Targets. |
|
34 | + * |
|
35 | + * @var Targets|null |
|
36 | + */ |
|
37 | + private $_merged; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor. |
|
41 | - * |
|
42 | - * @param bool $critical |
|
43 | - * @param Targets ...$targets |
|
44 | - */ |
|
45 | - public function __construct(bool $critical, Targets ...$targets) |
|
46 | - { |
|
47 | - parent::__construct(self::OID_TARGET_INFORMATION, $critical); |
|
48 | - $this->_targets = $targets; |
|
49 | - } |
|
39 | + /** |
|
40 | + * Constructor. |
|
41 | + * |
|
42 | + * @param bool $critical |
|
43 | + * @param Targets ...$targets |
|
44 | + */ |
|
45 | + public function __construct(bool $critical, Targets ...$targets) |
|
46 | + { |
|
47 | + parent::__construct(self::OID_TARGET_INFORMATION, $critical); |
|
48 | + $this->_targets = $targets; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Initialize from one or more Target objects. |
|
53 | - * |
|
54 | - * Extension criticality shall be set to true as specified by RFC 5755. |
|
55 | - * |
|
56 | - * @param Target ...$target |
|
57 | - * @return TargetInformationExtension |
|
58 | - */ |
|
59 | - public static function fromTargets(Target ...$target): self |
|
60 | - { |
|
61 | - return new self(true, new Targets(...$target)); |
|
62 | - } |
|
51 | + /** |
|
52 | + * Initialize from one or more Target objects. |
|
53 | + * |
|
54 | + * Extension criticality shall be set to true as specified by RFC 5755. |
|
55 | + * |
|
56 | + * @param Target ...$target |
|
57 | + * @return TargetInformationExtension |
|
58 | + */ |
|
59 | + public static function fromTargets(Target ...$target): self |
|
60 | + { |
|
61 | + return new self(true, new Targets(...$target)); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Reset internal state on clone. |
|
66 | - */ |
|
67 | - public function __clone() |
|
68 | - { |
|
69 | - $this->_merged = null; |
|
70 | - } |
|
64 | + /** |
|
65 | + * Reset internal state on clone. |
|
66 | + */ |
|
67 | + public function __clone() |
|
68 | + { |
|
69 | + $this->_merged = null; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * |
|
74 | - * {@inheritdoc} |
|
75 | - * @return self |
|
76 | - */ |
|
77 | - protected static function _fromDER(string $data, bool $critical): self |
|
78 | - { |
|
79 | - $targets = array_map( |
|
80 | - function (UnspecifiedType $el) { |
|
81 | - return Targets::fromASN1($el->asSequence()); |
|
82 | - }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
83 | - return new self($critical, ...$targets); |
|
84 | - } |
|
72 | + /** |
|
73 | + * |
|
74 | + * {@inheritdoc} |
|
75 | + * @return self |
|
76 | + */ |
|
77 | + protected static function _fromDER(string $data, bool $critical): self |
|
78 | + { |
|
79 | + $targets = array_map( |
|
80 | + function (UnspecifiedType $el) { |
|
81 | + return Targets::fromASN1($el->asSequence()); |
|
82 | + }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
|
83 | + return new self($critical, ...$targets); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get all targets. |
|
88 | - * |
|
89 | - * @return Targets |
|
90 | - */ |
|
91 | - public function targets(): Targets |
|
92 | - { |
|
93 | - if (!isset($this->_merged)) { |
|
94 | - $a = array(); |
|
95 | - foreach ($this->_targets as $targets) { |
|
96 | - $a = array_merge($a, $targets->all()); |
|
97 | - } |
|
98 | - $this->_merged = new Targets(...$a); |
|
99 | - } |
|
100 | - return $this->_merged; |
|
101 | - } |
|
86 | + /** |
|
87 | + * Get all targets. |
|
88 | + * |
|
89 | + * @return Targets |
|
90 | + */ |
|
91 | + public function targets(): Targets |
|
92 | + { |
|
93 | + if (!isset($this->_merged)) { |
|
94 | + $a = array(); |
|
95 | + foreach ($this->_targets as $targets) { |
|
96 | + $a = array_merge($a, $targets->all()); |
|
97 | + } |
|
98 | + $this->_merged = new Targets(...$a); |
|
99 | + } |
|
100 | + return $this->_merged; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Get all name targets. |
|
105 | - * |
|
106 | - * @return Target[] |
|
107 | - */ |
|
108 | - public function names(): array |
|
109 | - { |
|
110 | - return $this->targets()->nameTargets(); |
|
111 | - } |
|
103 | + /** |
|
104 | + * Get all name targets. |
|
105 | + * |
|
106 | + * @return Target[] |
|
107 | + */ |
|
108 | + public function names(): array |
|
109 | + { |
|
110 | + return $this->targets()->nameTargets(); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Get all group targets. |
|
115 | - * |
|
116 | - * @return Target[] |
|
117 | - */ |
|
118 | - public function groups(): array |
|
119 | - { |
|
120 | - return $this->targets()->groupTargets(); |
|
121 | - } |
|
113 | + /** |
|
114 | + * Get all group targets. |
|
115 | + * |
|
116 | + * @return Target[] |
|
117 | + */ |
|
118 | + public function groups(): array |
|
119 | + { |
|
120 | + return $this->targets()->groupTargets(); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * |
|
125 | - * @see \X509\Certificate\Extension\Extension::_valueASN1() |
|
126 | - * @return Sequence |
|
127 | - */ |
|
128 | - protected function _valueASN1(): Sequence |
|
129 | - { |
|
130 | - $elements = array_map( |
|
131 | - function (Targets $targets) { |
|
132 | - return $targets->toASN1(); |
|
133 | - }, $this->_targets); |
|
134 | - return new Sequence(...$elements); |
|
135 | - } |
|
123 | + /** |
|
124 | + * |
|
125 | + * @see \X509\Certificate\Extension\Extension::_valueASN1() |
|
126 | + * @return Sequence |
|
127 | + */ |
|
128 | + protected function _valueASN1(): Sequence |
|
129 | + { |
|
130 | + $elements = array_map( |
|
131 | + function (Targets $targets) { |
|
132 | + return $targets->toASN1(); |
|
133 | + }, $this->_targets); |
|
134 | + return new Sequence(...$elements); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * |
|
139 | - * @see \Countable::count() |
|
140 | - * @return int |
|
141 | - */ |
|
142 | - public function count(): int |
|
143 | - { |
|
144 | - return count($this->targets()); |
|
145 | - } |
|
137 | + /** |
|
138 | + * |
|
139 | + * @see \Countable::count() |
|
140 | + * @return int |
|
141 | + */ |
|
142 | + public function count(): int |
|
143 | + { |
|
144 | + return count($this->targets()); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Get iterator for targets. |
|
149 | - * |
|
150 | - * @see \IteratorAggregate::getIterator() |
|
151 | - * @return \ArrayIterator |
|
152 | - */ |
|
153 | - public function getIterator(): \ArrayIterator |
|
154 | - { |
|
155 | - return new \ArrayIterator($this->targets()->all()); |
|
156 | - } |
|
147 | + /** |
|
148 | + * Get iterator for targets. |
|
149 | + * |
|
150 | + * @see \IteratorAggregate::getIterator() |
|
151 | + * @return \ArrayIterator |
|
152 | + */ |
|
153 | + public function getIterator(): \ArrayIterator |
|
154 | + { |
|
155 | + return new \ArrayIterator($this->targets()->all()); |
|
156 | + } |
|
157 | 157 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected static function _fromDER(string $data, bool $critical): self |
78 | 78 | { |
79 | 79 | $targets = array_map( |
80 | - function (UnspecifiedType $el) { |
|
80 | + function(UnspecifiedType $el) { |
|
81 | 81 | return Targets::fromASN1($el->asSequence()); |
82 | 82 | }, UnspecifiedType::fromDER($data)->asSequence()->elements()); |
83 | 83 | return new self($critical, ...$targets); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | protected function _valueASN1(): Sequence |
129 | 129 | { |
130 | 130 | $elements = array_map( |
131 | - function (Targets $targets) { |
|
131 | + function(Targets $targets) { |
|
132 | 132 | return $targets->toASN1(); |
133 | 133 | }, $this->_targets); |
134 | 134 | return new Sequence(...$elements); |