@@ -17,94 +17,94 @@ |
||
17 | 17 | */ |
18 | 18 | class ExtensionRequestValue extends AttributeValue |
19 | 19 | { |
20 | - const OID = "1.2.840.113549.1.9.14"; |
|
20 | + const OID = "1.2.840.113549.1.9.14"; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Extensions. |
|
24 | - * |
|
25 | - * @var Extensions $_extensions |
|
26 | - */ |
|
27 | - protected $_extensions; |
|
22 | + /** |
|
23 | + * Extensions. |
|
24 | + * |
|
25 | + * @var Extensions $_extensions |
|
26 | + */ |
|
27 | + protected $_extensions; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Constructor. |
|
31 | - * |
|
32 | - * @param Extensions $extensions |
|
33 | - */ |
|
34 | - public function __construct(Extensions $extensions) |
|
35 | - { |
|
36 | - $this->_extensions = $extensions; |
|
37 | - $this->_oid = self::OID; |
|
38 | - } |
|
29 | + /** |
|
30 | + * Constructor. |
|
31 | + * |
|
32 | + * @param Extensions $extensions |
|
33 | + */ |
|
34 | + public function __construct(Extensions $extensions) |
|
35 | + { |
|
36 | + $this->_extensions = $extensions; |
|
37 | + $this->_oid = self::OID; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * |
|
42 | - * @see \X501\ASN1\AttributeValue\AttributeValue::fromASN1() |
|
43 | - * @param UnspecifiedType $el |
|
44 | - * @return self |
|
45 | - */ |
|
46 | - public static function fromASN1(UnspecifiedType $el): self |
|
47 | - { |
|
48 | - return new self(Extensions::fromASN1($el->asSequence())); |
|
49 | - } |
|
40 | + /** |
|
41 | + * |
|
42 | + * @see \X501\ASN1\AttributeValue\AttributeValue::fromASN1() |
|
43 | + * @param UnspecifiedType $el |
|
44 | + * @return self |
|
45 | + */ |
|
46 | + public static function fromASN1(UnspecifiedType $el): self |
|
47 | + { |
|
48 | + return new self(Extensions::fromASN1($el->asSequence())); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Get requested extensions. |
|
53 | - * |
|
54 | - * @return Extensions |
|
55 | - */ |
|
56 | - public function extensions(): Extensions |
|
57 | - { |
|
58 | - return $this->_extensions; |
|
59 | - } |
|
51 | + /** |
|
52 | + * Get requested extensions. |
|
53 | + * |
|
54 | + * @return Extensions |
|
55 | + */ |
|
56 | + public function extensions(): Extensions |
|
57 | + { |
|
58 | + return $this->_extensions; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * |
|
63 | - * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1() |
|
64 | - * @return Sequence |
|
65 | - */ |
|
66 | - public function toASN1(): Sequence |
|
67 | - { |
|
68 | - return $this->_extensions->toASN1(); |
|
69 | - } |
|
61 | + /** |
|
62 | + * |
|
63 | + * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1() |
|
64 | + * @return Sequence |
|
65 | + */ |
|
66 | + public function toASN1(): Sequence |
|
67 | + { |
|
68 | + return $this->_extensions->toASN1(); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * |
|
73 | - * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue() |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function stringValue(): string |
|
77 | - { |
|
78 | - return "#" . bin2hex($this->toASN1()->toDER()); |
|
79 | - } |
|
71 | + /** |
|
72 | + * |
|
73 | + * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue() |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function stringValue(): string |
|
77 | + { |
|
78 | + return "#" . bin2hex($this->toASN1()->toDER()); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * |
|
83 | - * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule() |
|
84 | - * @return BinaryMatch |
|
85 | - */ |
|
86 | - public function equalityMatchingRule(): BinaryMatch |
|
87 | - { |
|
88 | - return new BinaryMatch(); |
|
89 | - } |
|
81 | + /** |
|
82 | + * |
|
83 | + * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule() |
|
84 | + * @return BinaryMatch |
|
85 | + */ |
|
86 | + public function equalityMatchingRule(): BinaryMatch |
|
87 | + { |
|
88 | + return new BinaryMatch(); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * |
|
93 | - * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String() |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function rfc2253String(): string |
|
97 | - { |
|
98 | - return $this->stringValue(); |
|
99 | - } |
|
91 | + /** |
|
92 | + * |
|
93 | + * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String() |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function rfc2253String(): string |
|
97 | + { |
|
98 | + return $this->stringValue(); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * |
|
103 | - * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString() |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - protected function _transcodedString(): string |
|
107 | - { |
|
108 | - return $this->stringValue(); |
|
109 | - } |
|
101 | + /** |
|
102 | + * |
|
103 | + * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString() |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + protected function _transcodedString(): string |
|
107 | + { |
|
108 | + return $this->stringValue(); |
|
109 | + } |
|
110 | 110 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\CertificationRequest\Attribute; |
6 | 6 |
@@ -14,136 +14,136 @@ |
||
14 | 14 | */ |
15 | 15 | trait AttributeContainer |
16 | 16 | { |
17 | - /** |
|
18 | - * Array of attributes. |
|
19 | - * |
|
20 | - * @var Attribute[] $_attributes |
|
21 | - */ |
|
22 | - protected $_attributes; |
|
17 | + /** |
|
18 | + * Array of attributes. |
|
19 | + * |
|
20 | + * @var Attribute[] $_attributes |
|
21 | + */ |
|
22 | + protected $_attributes; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Find first attribute of given name or OID. |
|
26 | - * |
|
27 | - * @param string $name |
|
28 | - * @return Attribute|null |
|
29 | - */ |
|
30 | - protected function _findFirst(string $name) |
|
31 | - { |
|
32 | - $oid = AttributeType::attrNameToOID($name); |
|
33 | - foreach ($this->_attributes as $attr) { |
|
34 | - if ($attr->oid() == $oid) { |
|
35 | - return $attr; |
|
36 | - } |
|
37 | - } |
|
38 | - return null; |
|
39 | - } |
|
24 | + /** |
|
25 | + * Find first attribute of given name or OID. |
|
26 | + * |
|
27 | + * @param string $name |
|
28 | + * @return Attribute|null |
|
29 | + */ |
|
30 | + protected function _findFirst(string $name) |
|
31 | + { |
|
32 | + $oid = AttributeType::attrNameToOID($name); |
|
33 | + foreach ($this->_attributes as $attr) { |
|
34 | + if ($attr->oid() == $oid) { |
|
35 | + return $attr; |
|
36 | + } |
|
37 | + } |
|
38 | + return null; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Check whether attribute is present. |
|
43 | - * |
|
44 | - * @param string $name OID or attribute name |
|
45 | - * @return boolean |
|
46 | - */ |
|
47 | - public function has(string $name): bool |
|
48 | - { |
|
49 | - return null !== $this->_findFirst($name); |
|
50 | - } |
|
41 | + /** |
|
42 | + * Check whether attribute is present. |
|
43 | + * |
|
44 | + * @param string $name OID or attribute name |
|
45 | + * @return boolean |
|
46 | + */ |
|
47 | + public function has(string $name): bool |
|
48 | + { |
|
49 | + return null !== $this->_findFirst($name); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get first attribute by OID or attribute name. |
|
54 | - * |
|
55 | - * @param string $name OID or attribute name |
|
56 | - * @throws \OutOfBoundsException |
|
57 | - * @return Attribute |
|
58 | - */ |
|
59 | - public function firstOf(string $name): Attribute |
|
60 | - { |
|
61 | - $attr = $this->_findFirst($name); |
|
62 | - if (!$attr) { |
|
63 | - throw new \UnexpectedValueException("No $name attribute."); |
|
64 | - } |
|
65 | - return $attr; |
|
66 | - } |
|
52 | + /** |
|
53 | + * Get first attribute by OID or attribute name. |
|
54 | + * |
|
55 | + * @param string $name OID or attribute name |
|
56 | + * @throws \OutOfBoundsException |
|
57 | + * @return Attribute |
|
58 | + */ |
|
59 | + public function firstOf(string $name): Attribute |
|
60 | + { |
|
61 | + $attr = $this->_findFirst($name); |
|
62 | + if (!$attr) { |
|
63 | + throw new \UnexpectedValueException("No $name attribute."); |
|
64 | + } |
|
65 | + return $attr; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Get all attributes of given name. |
|
70 | - * |
|
71 | - * @param string $name OID or attribute name |
|
72 | - * @return Attribute[] |
|
73 | - */ |
|
74 | - public function allOf(string $name): array |
|
75 | - { |
|
76 | - $oid = AttributeType::attrNameToOID($name); |
|
77 | - $attrs = array_filter($this->_attributes, |
|
78 | - function (Attribute $attr) use ($oid) { |
|
79 | - return $attr->oid() == $oid; |
|
80 | - }); |
|
81 | - return array_values($attrs); |
|
82 | - } |
|
68 | + /** |
|
69 | + * Get all attributes of given name. |
|
70 | + * |
|
71 | + * @param string $name OID or attribute name |
|
72 | + * @return Attribute[] |
|
73 | + */ |
|
74 | + public function allOf(string $name): array |
|
75 | + { |
|
76 | + $oid = AttributeType::attrNameToOID($name); |
|
77 | + $attrs = array_filter($this->_attributes, |
|
78 | + function (Attribute $attr) use ($oid) { |
|
79 | + return $attr->oid() == $oid; |
|
80 | + }); |
|
81 | + return array_values($attrs); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Get all attributes. |
|
86 | - * |
|
87 | - * @return Attribute[] |
|
88 | - */ |
|
89 | - public function all(): array |
|
90 | - { |
|
91 | - return $this->_attributes; |
|
92 | - } |
|
84 | + /** |
|
85 | + * Get all attributes. |
|
86 | + * |
|
87 | + * @return Attribute[] |
|
88 | + */ |
|
89 | + public function all(): array |
|
90 | + { |
|
91 | + return $this->_attributes; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Get self with additional attributes added. |
|
96 | - * |
|
97 | - * @param Attribute ...$attribs |
|
98 | - * @return self |
|
99 | - */ |
|
100 | - public function withAdditional(Attribute ...$attribs): self |
|
101 | - { |
|
102 | - $obj = clone $this; |
|
103 | - foreach ($attribs as $attr) { |
|
104 | - $obj->_attributes[] = $attr; |
|
105 | - } |
|
106 | - return $obj; |
|
107 | - } |
|
94 | + /** |
|
95 | + * Get self with additional attributes added. |
|
96 | + * |
|
97 | + * @param Attribute ...$attribs |
|
98 | + * @return self |
|
99 | + */ |
|
100 | + public function withAdditional(Attribute ...$attribs): self |
|
101 | + { |
|
102 | + $obj = clone $this; |
|
103 | + foreach ($attribs as $attr) { |
|
104 | + $obj->_attributes[] = $attr; |
|
105 | + } |
|
106 | + return $obj; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Get self with single unique attribute added. |
|
111 | - * |
|
112 | - * All previous attributes of the same type are removed. |
|
113 | - * |
|
114 | - * @param Attribute $attr |
|
115 | - * @return self |
|
116 | - */ |
|
117 | - public function withUnique(Attribute $attr): self |
|
118 | - { |
|
119 | - $obj = clone $this; |
|
120 | - $obj->_attributes = array_filter($obj->_attributes, |
|
121 | - function (Attribute $a) use ($attr) { |
|
122 | - return $a->oid() != $attr->oid(); |
|
123 | - }); |
|
124 | - $obj->_attributes[] = $attr; |
|
125 | - return $obj; |
|
126 | - } |
|
109 | + /** |
|
110 | + * Get self with single unique attribute added. |
|
111 | + * |
|
112 | + * All previous attributes of the same type are removed. |
|
113 | + * |
|
114 | + * @param Attribute $attr |
|
115 | + * @return self |
|
116 | + */ |
|
117 | + public function withUnique(Attribute $attr): self |
|
118 | + { |
|
119 | + $obj = clone $this; |
|
120 | + $obj->_attributes = array_filter($obj->_attributes, |
|
121 | + function (Attribute $a) use ($attr) { |
|
122 | + return $a->oid() != $attr->oid(); |
|
123 | + }); |
|
124 | + $obj->_attributes[] = $attr; |
|
125 | + return $obj; |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Get number of attributes. |
|
130 | - * |
|
131 | - * @see \Countable::count() |
|
132 | - * @return int |
|
133 | - */ |
|
134 | - public function count(): int |
|
135 | - { |
|
136 | - return count($this->_attributes); |
|
137 | - } |
|
128 | + /** |
|
129 | + * Get number of attributes. |
|
130 | + * |
|
131 | + * @see \Countable::count() |
|
132 | + * @return int |
|
133 | + */ |
|
134 | + public function count(): int |
|
135 | + { |
|
136 | + return count($this->_attributes); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Get iterator for attributes. |
|
141 | - * |
|
142 | - * @see \IteratorAggregate::getIterator() |
|
143 | - * @return \ArrayIterator |
|
144 | - */ |
|
145 | - public function getIterator(): \ArrayIterator |
|
146 | - { |
|
147 | - return new \ArrayIterator($this->_attributes); |
|
148 | - } |
|
139 | + /** |
|
140 | + * Get iterator for attributes. |
|
141 | + * |
|
142 | + * @see \IteratorAggregate::getIterator() |
|
143 | + * @return \ArrayIterator |
|
144 | + */ |
|
145 | + public function getIterator(): \ArrayIterator |
|
146 | + { |
|
147 | + return new \ArrayIterator($this->_attributes); |
|
148 | + } |
|
149 | 149 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\Feature; |
6 | 6 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | $oid = AttributeType::attrNameToOID($name); |
77 | 77 | $attrs = array_filter($this->_attributes, |
78 | - function (Attribute $attr) use ($oid) { |
|
78 | + function(Attribute $attr) use ($oid) { |
|
79 | 79 | return $attr->oid() == $oid; |
80 | 80 | }); |
81 | 81 | return array_values($attrs); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $obj = clone $this; |
120 | 120 | $obj->_attributes = array_filter($obj->_attributes, |
121 | - function (Attribute $a) use ($attr) { |
|
121 | + function(Attribute $a) use ($attr) { |
|
122 | 122 | return $a->oid() != $attr->oid(); |
123 | 123 | }); |
124 | 124 | $obj->_attributes[] = $attr; |
@@ -9,69 +9,69 @@ |
||
9 | 9 | */ |
10 | 10 | trait DateTimeHelper |
11 | 11 | { |
12 | - /** |
|
13 | - * Create DateTime object from time string and timezone. |
|
14 | - * |
|
15 | - * @param string|null $time Time string, default to 'now' |
|
16 | - * @param string|null $tz Timezone, default if omitted |
|
17 | - * @throws \RuntimeException |
|
18 | - * @return \DateTimeImmutable |
|
19 | - */ |
|
20 | - private static function _createDateTime($time = null, $tz = null): \DateTimeImmutable |
|
21 | - { |
|
22 | - if (!isset($time)) { |
|
23 | - $time = 'now'; |
|
24 | - } |
|
25 | - if (!isset($tz)) { |
|
26 | - $tz = date_default_timezone_get(); |
|
27 | - } |
|
28 | - try { |
|
29 | - $dt = new \DateTimeImmutable($time, self::_createTimeZone($tz)); |
|
30 | - return self::_roundDownFractionalSeconds($dt); |
|
31 | - } catch (\Exception $e) { |
|
32 | - throw new \RuntimeException( |
|
33 | - "Failed to create DateTime: " . |
|
34 | - self::_getLastDateTimeImmutableErrorsStr(), 0, $e); |
|
35 | - } |
|
36 | - } |
|
12 | + /** |
|
13 | + * Create DateTime object from time string and timezone. |
|
14 | + * |
|
15 | + * @param string|null $time Time string, default to 'now' |
|
16 | + * @param string|null $tz Timezone, default if omitted |
|
17 | + * @throws \RuntimeException |
|
18 | + * @return \DateTimeImmutable |
|
19 | + */ |
|
20 | + private static function _createDateTime($time = null, $tz = null): \DateTimeImmutable |
|
21 | + { |
|
22 | + if (!isset($time)) { |
|
23 | + $time = 'now'; |
|
24 | + } |
|
25 | + if (!isset($tz)) { |
|
26 | + $tz = date_default_timezone_get(); |
|
27 | + } |
|
28 | + try { |
|
29 | + $dt = new \DateTimeImmutable($time, self::_createTimeZone($tz)); |
|
30 | + return self::_roundDownFractionalSeconds($dt); |
|
31 | + } catch (\Exception $e) { |
|
32 | + throw new \RuntimeException( |
|
33 | + "Failed to create DateTime: " . |
|
34 | + self::_getLastDateTimeImmutableErrorsStr(), 0, $e); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Rounds a \DateTimeImmutable value such that fractional |
|
40 | - * seconds are removed. |
|
41 | - * |
|
42 | - * @param \DateTimeImmutable $dt |
|
43 | - * @return \DateTimeImmutable |
|
44 | - */ |
|
45 | - private static function _roundDownFractionalSeconds(\DateTimeImmutable $dt): \DateTimeImmutable |
|
46 | - { |
|
47 | - return \DateTimeImmutable::createFromFormat("Y-m-d H:i:s", |
|
48 | - $dt->format("Y-m-d H:i:s"), $dt->getTimezone()); |
|
49 | - } |
|
38 | + /** |
|
39 | + * Rounds a \DateTimeImmutable value such that fractional |
|
40 | + * seconds are removed. |
|
41 | + * |
|
42 | + * @param \DateTimeImmutable $dt |
|
43 | + * @return \DateTimeImmutable |
|
44 | + */ |
|
45 | + private static function _roundDownFractionalSeconds(\DateTimeImmutable $dt): \DateTimeImmutable |
|
46 | + { |
|
47 | + return \DateTimeImmutable::createFromFormat("Y-m-d H:i:s", |
|
48 | + $dt->format("Y-m-d H:i:s"), $dt->getTimezone()); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Create DateTimeZone object from string. |
|
53 | - * |
|
54 | - * @param string $tz |
|
55 | - * @throws \UnexpectedValueException |
|
56 | - * @return \DateTimeZone |
|
57 | - */ |
|
58 | - private static function _createTimeZone(string $tz): \DateTimeZone |
|
59 | - { |
|
60 | - try { |
|
61 | - return new \DateTimeZone($tz); |
|
62 | - } catch (\Exception $e) { |
|
63 | - throw new \UnexpectedValueException("Invalid timezone.", 0, $e); |
|
64 | - } |
|
65 | - } |
|
51 | + /** |
|
52 | + * Create DateTimeZone object from string. |
|
53 | + * |
|
54 | + * @param string $tz |
|
55 | + * @throws \UnexpectedValueException |
|
56 | + * @return \DateTimeZone |
|
57 | + */ |
|
58 | + private static function _createTimeZone(string $tz): \DateTimeZone |
|
59 | + { |
|
60 | + try { |
|
61 | + return new \DateTimeZone($tz); |
|
62 | + } catch (\Exception $e) { |
|
63 | + throw new \UnexpectedValueException("Invalid timezone.", 0, $e); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Get last error caused by DateTimeImmutable. |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - private static function _getLastDateTimeImmutableErrorsStr(): string |
|
73 | - { |
|
74 | - $errors = \DateTimeImmutable::getLastErrors()["errors"]; |
|
75 | - return implode(", ", $errors); |
|
76 | - } |
|
67 | + /** |
|
68 | + * Get last error caused by DateTimeImmutable. |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + private static function _getLastDateTimeImmutableErrorsStr(): string |
|
73 | + { |
|
74 | + $errors = \DateTimeImmutable::getLastErrors()["errors"]; |
|
75 | + return implode(", ", $errors); |
|
76 | + } |
|
77 | 77 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\Feature; |
6 | 6 |
@@ -16,59 +16,59 @@ |
||
16 | 16 | */ |
17 | 17 | class RFC822Name extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * Email. |
|
21 | - * |
|
22 | - * @var string $_email |
|
23 | - */ |
|
24 | - protected $_email; |
|
19 | + /** |
|
20 | + * Email. |
|
21 | + * |
|
22 | + * @var string $_email |
|
23 | + */ |
|
24 | + protected $_email; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param string $email |
|
30 | - */ |
|
31 | - public function __construct(string $email) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_RFC822_NAME; |
|
34 | - $this->_email = $email; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param string $email |
|
30 | + */ |
|
31 | + public function __construct(string $email) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_RFC822_NAME; |
|
34 | + $this->_email = $email; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * |
|
39 | - * @param UnspecifiedType $el |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): self |
|
43 | - { |
|
44 | - return new self($el->asIA5String()->string()); |
|
45 | - } |
|
37 | + /** |
|
38 | + * |
|
39 | + * @param UnspecifiedType $el |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): self |
|
43 | + { |
|
44 | + return new self($el->asIA5String()->string()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * |
|
49 | - * {@inheritdoc} |
|
50 | - */ |
|
51 | - public function string(): string |
|
52 | - { |
|
53 | - return $this->_email; |
|
54 | - } |
|
47 | + /** |
|
48 | + * |
|
49 | + * {@inheritdoc} |
|
50 | + */ |
|
51 | + public function string(): string |
|
52 | + { |
|
53 | + return $this->_email; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get email. |
|
58 | - * |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function email(): string |
|
62 | - { |
|
63 | - return $this->_email; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Get email. |
|
58 | + * |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function email(): string |
|
62 | + { |
|
63 | + return $this->_email; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - protected function _choiceASN1(): TaggedType |
|
71 | - { |
|
72 | - return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_email)); |
|
73 | - } |
|
66 | + /** |
|
67 | + * |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + protected function _choiceASN1(): TaggedType |
|
71 | + { |
|
72 | + return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_email)); |
|
73 | + } |
|
74 | 74 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\GeneralName; |
6 | 6 |
@@ -18,47 +18,47 @@ |
||
18 | 18 | */ |
19 | 19 | class EDIPartyName extends GeneralName |
20 | 20 | { |
21 | - /** |
|
22 | - * |
|
23 | - * @var \ASN1\Element |
|
24 | - */ |
|
25 | - protected $_element; |
|
21 | + /** |
|
22 | + * |
|
23 | + * @var \ASN1\Element |
|
24 | + */ |
|
25 | + protected $_element; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - */ |
|
30 | - protected function __construct() |
|
31 | - { |
|
32 | - $this->_tag = self::TAG_EDI_PARTY_NAME; |
|
33 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + */ |
|
30 | + protected function __construct() |
|
31 | + { |
|
32 | + $this->_tag = self::TAG_EDI_PARTY_NAME; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * |
|
37 | - * @param UnspecifiedType $el |
|
38 | - * @return self |
|
39 | - */ |
|
40 | - public static function fromChosenASN1(UnspecifiedType $el): self |
|
41 | - { |
|
42 | - $obj = new self(); |
|
43 | - $obj->_element = $el->asSequence(); |
|
44 | - return $obj; |
|
45 | - } |
|
35 | + /** |
|
36 | + * |
|
37 | + * @param UnspecifiedType $el |
|
38 | + * @return self |
|
39 | + */ |
|
40 | + public static function fromChosenASN1(UnspecifiedType $el): self |
|
41 | + { |
|
42 | + $obj = new self(); |
|
43 | + $obj->_element = $el->asSequence(); |
|
44 | + return $obj; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * |
|
49 | - * {@inheritdoc} |
|
50 | - */ |
|
51 | - public function string(): string |
|
52 | - { |
|
53 | - return bin2hex($this->_element->toDER()); |
|
54 | - } |
|
47 | + /** |
|
48 | + * |
|
49 | + * {@inheritdoc} |
|
50 | + */ |
|
51 | + public function string(): string |
|
52 | + { |
|
53 | + return bin2hex($this->_element->toDER()); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * |
|
58 | - * {@inheritdoc} |
|
59 | - */ |
|
60 | - protected function _choiceASN1(): TaggedType |
|
61 | - { |
|
62 | - return new ImplicitlyTaggedType($this->_tag, $this->_element); |
|
63 | - } |
|
56 | + /** |
|
57 | + * |
|
58 | + * {@inheritdoc} |
|
59 | + */ |
|
60 | + protected function _choiceASN1(): TaggedType |
|
61 | + { |
|
62 | + return new ImplicitlyTaggedType($this->_tag, $this->_element); |
|
63 | + } |
|
64 | 64 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\GeneralName; |
6 | 6 |
@@ -19,87 +19,87 @@ |
||
19 | 19 | */ |
20 | 20 | class OtherName extends GeneralName |
21 | 21 | { |
22 | - /** |
|
23 | - * Type OID. |
|
24 | - * |
|
25 | - * @var string $_type |
|
26 | - */ |
|
27 | - protected $_type; |
|
22 | + /** |
|
23 | + * Type OID. |
|
24 | + * |
|
25 | + * @var string $_type |
|
26 | + */ |
|
27 | + protected $_type; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Value. |
|
31 | - * |
|
32 | - * @var Element $_element |
|
33 | - */ |
|
34 | - protected $_element; |
|
29 | + /** |
|
30 | + * Value. |
|
31 | + * |
|
32 | + * @var Element $_element |
|
33 | + */ |
|
34 | + protected $_element; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor. |
|
38 | - * |
|
39 | - * @param string $type_id OID |
|
40 | - * @param Element $el |
|
41 | - */ |
|
42 | - public function __construct(string $type_id, Element $el) |
|
43 | - { |
|
44 | - $this->_tag = self::TAG_OTHER_NAME; |
|
45 | - $this->_type = $type_id; |
|
46 | - $this->_element = $el; |
|
47 | - } |
|
36 | + /** |
|
37 | + * Constructor. |
|
38 | + * |
|
39 | + * @param string $type_id OID |
|
40 | + * @param Element $el |
|
41 | + */ |
|
42 | + public function __construct(string $type_id, Element $el) |
|
43 | + { |
|
44 | + $this->_tag = self::TAG_OTHER_NAME; |
|
45 | + $this->_type = $type_id; |
|
46 | + $this->_element = $el; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * @param UnspecifiedType $el |
|
52 | - * @return self |
|
53 | - */ |
|
54 | - public static function fromChosenASN1(UnspecifiedType $el): self |
|
55 | - { |
|
56 | - $seq = $el->asSequence(); |
|
57 | - $type_id = $seq->at(0) |
|
58 | - ->asObjectIdentifier() |
|
59 | - ->oid(); |
|
60 | - $value = $seq->getTagged(0) |
|
61 | - ->asExplicit() |
|
62 | - ->asElement(); |
|
63 | - return new self($type_id, $value); |
|
64 | - } |
|
49 | + /** |
|
50 | + * |
|
51 | + * @param UnspecifiedType $el |
|
52 | + * @return self |
|
53 | + */ |
|
54 | + public static function fromChosenASN1(UnspecifiedType $el): self |
|
55 | + { |
|
56 | + $seq = $el->asSequence(); |
|
57 | + $type_id = $seq->at(0) |
|
58 | + ->asObjectIdentifier() |
|
59 | + ->oid(); |
|
60 | + $value = $seq->getTagged(0) |
|
61 | + ->asExplicit() |
|
62 | + ->asElement(); |
|
63 | + return new self($type_id, $value); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - public function string(): string |
|
71 | - { |
|
72 | - return $this->_type . "/#" . bin2hex($this->_element->toDER()); |
|
73 | - } |
|
66 | + /** |
|
67 | + * |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + public function string(): string |
|
71 | + { |
|
72 | + return $this->_type . "/#" . bin2hex($this->_element->toDER()); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Get type OID. |
|
77 | - * |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public function type(): string |
|
81 | - { |
|
82 | - return $this->_type; |
|
83 | - } |
|
75 | + /** |
|
76 | + * Get type OID. |
|
77 | + * |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public function type(): string |
|
81 | + { |
|
82 | + return $this->_type; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Get value element. |
|
87 | - * |
|
88 | - * @return Element |
|
89 | - */ |
|
90 | - public function value(): Element |
|
91 | - { |
|
92 | - return $this->_element; |
|
93 | - } |
|
85 | + /** |
|
86 | + * Get value element. |
|
87 | + * |
|
88 | + * @return Element |
|
89 | + */ |
|
90 | + public function value(): Element |
|
91 | + { |
|
92 | + return $this->_element; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * |
|
97 | - * {@inheritdoc} |
|
98 | - */ |
|
99 | - protected function _choiceASN1(): TaggedType |
|
100 | - { |
|
101 | - return new ImplicitlyTaggedType($this->_tag, |
|
102 | - new Sequence(new ObjectIdentifier($this->_type), |
|
103 | - new ExplicitlyTaggedType(0, $this->_element))); |
|
104 | - } |
|
95 | + /** |
|
96 | + * |
|
97 | + * {@inheritdoc} |
|
98 | + */ |
|
99 | + protected function _choiceASN1(): TaggedType |
|
100 | + { |
|
101 | + return new ImplicitlyTaggedType($this->_tag, |
|
102 | + new Sequence(new ObjectIdentifier($this->_type), |
|
103 | + new ExplicitlyTaggedType(0, $this->_element))); |
|
104 | + } |
|
105 | 105 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\GeneralName; |
6 | 6 |
@@ -17,59 +17,59 @@ |
||
17 | 17 | */ |
18 | 18 | class UniformResourceIdentifier extends GeneralName |
19 | 19 | { |
20 | - /** |
|
21 | - * URI. |
|
22 | - * |
|
23 | - * @var string $_uri |
|
24 | - */ |
|
25 | - protected $_uri; |
|
20 | + /** |
|
21 | + * URI. |
|
22 | + * |
|
23 | + * @var string $_uri |
|
24 | + */ |
|
25 | + protected $_uri; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param string $uri |
|
31 | - */ |
|
32 | - public function __construct(string $uri) |
|
33 | - { |
|
34 | - $this->_tag = self::TAG_URI; |
|
35 | - $this->_uri = $uri; |
|
36 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param string $uri |
|
31 | + */ |
|
32 | + public function __construct(string $uri) |
|
33 | + { |
|
34 | + $this->_tag = self::TAG_URI; |
|
35 | + $this->_uri = $uri; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * |
|
40 | - * @param UnspecifiedType $el |
|
41 | - * @return self |
|
42 | - */ |
|
43 | - public static function fromChosenASN1(UnspecifiedType $el): self |
|
44 | - { |
|
45 | - return new self($el->asIA5String()->string()); |
|
46 | - } |
|
38 | + /** |
|
39 | + * |
|
40 | + * @param UnspecifiedType $el |
|
41 | + * @return self |
|
42 | + */ |
|
43 | + public static function fromChosenASN1(UnspecifiedType $el): self |
|
44 | + { |
|
45 | + return new self($el->asIA5String()->string()); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * |
|
50 | - * {@inheritdoc} |
|
51 | - */ |
|
52 | - public function string(): string |
|
53 | - { |
|
54 | - return $this->_uri; |
|
55 | - } |
|
48 | + /** |
|
49 | + * |
|
50 | + * {@inheritdoc} |
|
51 | + */ |
|
52 | + public function string(): string |
|
53 | + { |
|
54 | + return $this->_uri; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Get URI. |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function uri(): string |
|
63 | - { |
|
64 | - return $this->_uri; |
|
65 | - } |
|
57 | + /** |
|
58 | + * Get URI. |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function uri(): string |
|
63 | + { |
|
64 | + return $this->_uri; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * |
|
69 | - * {@inheritdoc} |
|
70 | - */ |
|
71 | - protected function _choiceASN1(): TaggedType |
|
72 | - { |
|
73 | - return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_uri)); |
|
74 | - } |
|
67 | + /** |
|
68 | + * |
|
69 | + * {@inheritdoc} |
|
70 | + */ |
|
71 | + protected function _choiceASN1(): TaggedType |
|
72 | + { |
|
73 | + return new ImplicitlyTaggedType($this->_tag, new IA5String($this->_uri)); |
|
74 | + } |
|
75 | 75 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\GeneralName; |
6 | 6 |
@@ -16,60 +16,60 @@ |
||
16 | 16 | */ |
17 | 17 | class RegisteredID extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * Object identifier. |
|
21 | - * |
|
22 | - * @var string $_oid |
|
23 | - */ |
|
24 | - protected $_oid; |
|
19 | + /** |
|
20 | + * Object identifier. |
|
21 | + * |
|
22 | + * @var string $_oid |
|
23 | + */ |
|
24 | + protected $_oid; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param string $oid OID in dotted format |
|
30 | - */ |
|
31 | - public function __construct(string $oid) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_REGISTERED_ID; |
|
34 | - $this->_oid = $oid; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param string $oid OID in dotted format |
|
30 | + */ |
|
31 | + public function __construct(string $oid) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_REGISTERED_ID; |
|
34 | + $this->_oid = $oid; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * |
|
39 | - * @param UnspecifiedType $el |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): self |
|
43 | - { |
|
44 | - return new self($el->asObjectIdentifier()->oid()); |
|
45 | - } |
|
37 | + /** |
|
38 | + * |
|
39 | + * @param UnspecifiedType $el |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): self |
|
43 | + { |
|
44 | + return new self($el->asObjectIdentifier()->oid()); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * |
|
49 | - * {@inheritdoc} |
|
50 | - */ |
|
51 | - public function string(): string |
|
52 | - { |
|
53 | - return $this->_oid; |
|
54 | - } |
|
47 | + /** |
|
48 | + * |
|
49 | + * {@inheritdoc} |
|
50 | + */ |
|
51 | + public function string(): string |
|
52 | + { |
|
53 | + return $this->_oid; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get object identifier in dotted format. |
|
58 | - * |
|
59 | - * @return string OID |
|
60 | - */ |
|
61 | - public function oid(): string |
|
62 | - { |
|
63 | - return $this->_oid; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Get object identifier in dotted format. |
|
58 | + * |
|
59 | + * @return string OID |
|
60 | + */ |
|
61 | + public function oid(): string |
|
62 | + { |
|
63 | + return $this->_oid; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - protected function _choiceASN1(): TaggedType |
|
71 | - { |
|
72 | - return new ImplicitlyTaggedType($this->_tag, |
|
73 | - new ObjectIdentifier($this->_oid)); |
|
74 | - } |
|
66 | + /** |
|
67 | + * |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + protected function _choiceASN1(): TaggedType |
|
71 | + { |
|
72 | + return new ImplicitlyTaggedType($this->_tag, |
|
73 | + new ObjectIdentifier($this->_oid)); |
|
74 | + } |
|
75 | 75 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\GeneralName; |
6 | 6 |
@@ -16,72 +16,72 @@ |
||
16 | 16 | */ |
17 | 17 | class DirectoryName extends GeneralName |
18 | 18 | { |
19 | - /** |
|
20 | - * Directory name. |
|
21 | - * |
|
22 | - * @var Name $_dn |
|
23 | - */ |
|
24 | - protected $_dn; |
|
19 | + /** |
|
20 | + * Directory name. |
|
21 | + * |
|
22 | + * @var Name $_dn |
|
23 | + */ |
|
24 | + protected $_dn; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Constructor. |
|
28 | - * |
|
29 | - * @param Name $dn |
|
30 | - */ |
|
31 | - public function __construct(Name $dn) |
|
32 | - { |
|
33 | - $this->_tag = self::TAG_DIRECTORY_NAME; |
|
34 | - $this->_dn = $dn; |
|
35 | - } |
|
26 | + /** |
|
27 | + * Constructor. |
|
28 | + * |
|
29 | + * @param Name $dn |
|
30 | + */ |
|
31 | + public function __construct(Name $dn) |
|
32 | + { |
|
33 | + $this->_tag = self::TAG_DIRECTORY_NAME; |
|
34 | + $this->_dn = $dn; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * |
|
39 | - * @param UnspecifiedType $el |
|
40 | - * @return self |
|
41 | - */ |
|
42 | - public static function fromChosenASN1(UnspecifiedType $el): self |
|
43 | - { |
|
44 | - return new self(Name::fromASN1($el->asSequence())); |
|
45 | - } |
|
37 | + /** |
|
38 | + * |
|
39 | + * @param UnspecifiedType $el |
|
40 | + * @return self |
|
41 | + */ |
|
42 | + public static function fromChosenASN1(UnspecifiedType $el): self |
|
43 | + { |
|
44 | + return new self(Name::fromASN1($el->asSequence())); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Initialize from distinguished name string. |
|
49 | - * |
|
50 | - * @param string $str |
|
51 | - * @return self |
|
52 | - */ |
|
53 | - public static function fromDNString(string $str): self |
|
54 | - { |
|
55 | - return new self(Name::fromString($str)); |
|
56 | - } |
|
47 | + /** |
|
48 | + * Initialize from distinguished name string. |
|
49 | + * |
|
50 | + * @param string $str |
|
51 | + * @return self |
|
52 | + */ |
|
53 | + public static function fromDNString(string $str): self |
|
54 | + { |
|
55 | + return new self(Name::fromString($str)); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * |
|
60 | - * {@inheritdoc} |
|
61 | - */ |
|
62 | - public function string(): string |
|
63 | - { |
|
64 | - return $this->_dn->toString(); |
|
65 | - } |
|
58 | + /** |
|
59 | + * |
|
60 | + * {@inheritdoc} |
|
61 | + */ |
|
62 | + public function string(): string |
|
63 | + { |
|
64 | + return $this->_dn->toString(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Get directory name. |
|
69 | - * |
|
70 | - * @return Name |
|
71 | - */ |
|
72 | - public function dn(): Name |
|
73 | - { |
|
74 | - return $this->_dn; |
|
75 | - } |
|
67 | + /** |
|
68 | + * Get directory name. |
|
69 | + * |
|
70 | + * @return Name |
|
71 | + */ |
|
72 | + public function dn(): Name |
|
73 | + { |
|
74 | + return $this->_dn; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * |
|
79 | - * {@inheritdoc} |
|
80 | - */ |
|
81 | - protected function _choiceASN1(): TaggedType |
|
82 | - { |
|
83 | - // Name type is itself a CHOICE, so explicit tagging must be |
|
84 | - // employed to avoid ambiguities |
|
85 | - return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1()); |
|
86 | - } |
|
77 | + /** |
|
78 | + * |
|
79 | + * {@inheritdoc} |
|
80 | + */ |
|
81 | + protected function _choiceASN1(): TaggedType |
|
82 | + { |
|
83 | + // Name type is itself a CHOICE, so explicit tagging must be |
|
84 | + // employed to avoid ambiguities |
|
85 | + return new ExplicitlyTaggedType($this->_tag, $this->_dn->toASN1()); |
|
86 | + } |
|
87 | 87 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace X509\GeneralName; |
6 | 6 |