1 | <?php |
||
23 | class TermList implements Countable, IteratorAggregate, Comparable { |
||
24 | |||
25 | /** |
||
26 | * @var Term[] |
||
27 | */ |
||
28 | private $terms = []; |
||
29 | |||
30 | /** |
||
31 | * @param Term[] $terms |
||
32 | * @throws InvalidArgumentException |
||
33 | 39 | */ |
|
34 | 39 | public function __construct( array $terms = [] ) { |
|
43 | |||
44 | /** |
||
45 | * @see Countable::count |
||
46 | * @return int |
||
47 | 7 | */ |
|
48 | 7 | public function count() { |
|
51 | |||
52 | /** |
||
53 | * Returns an array with language codes as keys and the term text as values. |
||
54 | * |
||
55 | * @return string[] |
||
56 | 2 | */ |
|
57 | 2 | public function toTextArray() { |
|
66 | |||
67 | /** |
||
68 | * @see IteratorAggregate::getIterator |
||
69 | * @return Iterator|Term[] |
||
70 | 4 | */ |
|
71 | 4 | public function getIterator() { |
|
74 | |||
75 | /** |
||
76 | * @param string $languageCode |
||
77 | * |
||
78 | * @return Term |
||
79 | * @throws OutOfBoundsException |
||
80 | */ |
||
81 | 6 | public function getByLanguage( $languageCode ) { |
|
88 | 2 | ||
89 | /** |
||
90 | * @since 2.5 |
||
91 | * |
||
92 | * @param string[] $languageCodes |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | public function getWithLanguages( array $languageCodes ) { |
||
99 | 4 | ||
100 | /** |
||
101 | * @param string $languageCode |
||
102 | 5 | */ |
|
103 | 5 | public function removeByLanguage( $languageCode ) { |
|
106 | |||
107 | 4 | /** |
|
108 | 4 | * @param string $languageCode |
|
109 | 1 | * |
|
110 | * @return bool |
||
111 | */ |
||
112 | 15 | public function hasTermForLanguage( $languageCode ) { |
|
115 | |||
116 | 6 | /** |
|
117 | * Replaces non-empty or removes empty terms. |
||
118 | 6 | * |
|
119 | 6 | * @param Term $term |
|
120 | 6 | */ |
|
121 | public function setTerm( Term $term ) { |
||
128 | 6 | ||
129 | 6 | /** |
|
130 | 4 | * @since 0.8 |
|
131 | * |
||
132 | * @param string $languageCode |
||
133 | * @param string $termText |
||
134 | */ |
||
135 | public function setTextForLanguage( $languageCode, $termText ) { |
||
138 | |||
139 | /** |
||
140 | * @see Comparable::equals |
||
141 | 5 | * |
|
142 | 5 | * @since 0.7.4 |
|
143 | 1 | * |
|
144 | * @param mixed $target |
||
145 | * |
||
146 | 5 | * @return bool |
|
147 | 5 | */ |
|
148 | 5 | public function equals( $target ) { |
|
167 | 1 | ||
168 | /** |
||
169 | * @since 2.4.0 |
||
170 | * |
||
171 | * @return bool |
||
172 | */ |
||
173 | public function isEmpty() { |
||
176 | |||
177 | 6 | /** |
|
178 | 6 | * @since 0.7.4 |
|
179 | 6 | * |
|
180 | * @param Term $term |
||
181 | * |
||
182 | * @return boolean |
||
183 | */ |
||
184 | public function hasTerm( Term $term ) { |
||
188 | |||
189 | /** |
||
190 | * Removes all terms from this list. |
||
191 | * |
||
192 | * @since 7.0 |
||
193 | */ |
||
194 | public function clear() { |
||
197 | |||
198 | /** |
||
199 | * @since 8.1 |
||
200 | * |
||
201 | * @param iterable|Term[] $terms |
||
202 | */ |
||
203 | public function addAll( /* iterable */ $terms ) { |
||
208 | |||
209 | } |
||
210 |