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 | 40 | 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() { |
|
88 | 15 | $parts = array_map( |
|
89 | function (AttributeTypeAndValue $tv) { |
||
90 | 15 | return $tv->toString(); |
|
91 | 15 | }, $this->_attribs); |
|
92 | 15 | return implode("+", $parts); |
|
93 | } |
||
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 all AttributeTypeAndValue objects of the given attribute type. |
||
134 | * |
||
135 | * @param string $name Attribute OID or name |
||
136 | * @return AttributeTypeAndValue[] |
||
137 | */ |
||
138 | 8 | public function allOf($name) { |
|
146 | |||
147 | /** |
||
148 | * |
||
149 | * @see Countable::count() |
||
150 | * @return int |
||
151 | */ |
||
152 | 23 | public function count() { |
|
155 | |||
156 | /** |
||
157 | * |
||
158 | * @see IteratorAggregate::getIterator() |
||
159 | * @return \ArrayIterator |
||
160 | */ |
||
161 | 1 | public function getIterator() { |
|
164 | |||
165 | /** |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | 1 | public function __toString() { |
|
172 | } |
||
173 |