1 | <?php |
||
16 | class RDN implements \Countable, \IteratorAggregate |
||
17 | { |
||
18 | /** |
||
19 | * Attributes. |
||
20 | * |
||
21 | * @var AttributeTypeAndValue[] $_attribs |
||
22 | */ |
||
23 | protected $_attribs; |
||
24 | |||
25 | /** |
||
26 | * Constructor |
||
27 | * |
||
28 | * @param AttributeTypeAndValue ...$attribs One or more attributes |
||
29 | */ |
||
30 | 39 | public function __construct(AttributeTypeAndValue ...$attribs) { |
|
37 | |||
38 | /** |
||
39 | * Convenience method to initialize RDN from AttributeValue objects. |
||
40 | * |
||
41 | * @param AttributeValue ...$values One or more attributes |
||
42 | * @return self |
||
43 | */ |
||
44 | 1 | public static function fromAttributeValues(AttributeValue ...$values) { |
|
52 | |||
53 | /** |
||
54 | * Initialize from ASN.1. |
||
55 | * |
||
56 | * @param Set $set |
||
57 | * @return self |
||
58 | */ |
||
59 | 4 | public static function fromASN1(Set $set) { |
|
66 | |||
67 | /** |
||
68 | * Generate ASN.1 structure. |
||
69 | * |
||
70 | * @return Set |
||
71 | */ |
||
72 | 4 | public function toASN1() { |
|
80 | |||
81 | /** |
||
82 | * Get name-component string conforming to RFC 2253. |
||
83 | * |
||
84 | * @link https://tools.ietf.org/html/rfc2253#section-2.2 |
||
85 | * @return string |
||
86 | */ |
||
87 | 15 | public function toString() { |
|
94 | |||
95 | /** |
||
96 | * Check whether RDN is semantically equal to other. |
||
97 | * |
||
98 | * @param RDN $other Object to compare to |
||
99 | * @return bool |
||
100 | */ |
||
101 | 22 | public function equals(RDN $other) { |
|
122 | |||
123 | /** |
||
124 | * Get all AttributeTypeAndValue objects. |
||
125 | * |
||
126 | * @return AttributeTypeAndValue[] |
||
127 | */ |
||
128 | 1 | public function all() { |
|
131 | |||
132 | /** |
||
133 | * Get the first AttributeTypeAndValue object in RDN. |
||
134 | * |
||
135 | * @return AttributeTypeAndValue |
||
136 | */ |
||
137 | 1 | public function first() { |
|
140 | |||
141 | /** |
||
142 | * Find the first AttributeTypeAndValue object of given OID. |
||
143 | * |
||
144 | * @param string $oid Object identifier in dotted format |
||
145 | * @return AttributeTypeAndValue|null Null if not found |
||
146 | */ |
||
147 | 4 | protected function _findFirstOf($oid) { |
|
155 | |||
156 | /** |
||
157 | * Check whether RDN has an attribute of given type. |
||
158 | * |
||
159 | * @param string $name Attribute name or OID |
||
160 | * @return boolean |
||
161 | */ |
||
162 | 2 | public function has($name) { |
|
166 | |||
167 | /** |
||
168 | * Get the first AttributeTypeAndValue object of given attribute type. |
||
169 | * |
||
170 | * @param string $name Attribute name or OID |
||
171 | * @throws \LogicException If attribute doesn't exists |
||
172 | * @return AttributeTypeAndValue |
||
173 | */ |
||
174 | 2 | public function firstOf($name) { |
|
182 | |||
183 | /** |
||
184 | * |
||
185 | * @see Countable::count() |
||
186 | * @return int |
||
187 | */ |
||
188 | 23 | public function count() { |
|
191 | |||
192 | /** |
||
193 | * |
||
194 | * @see IteratorAggregate::getIterator() |
||
195 | * @return \ArrayIterator |
||
196 | */ |
||
197 | 1 | public function getIterator() { |
|
200 | |||
201 | /** |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | 1 | public function __toString() { |
|
208 | } |
||
209 |