1 | <?php |
||
58 | class Item implements ItemInterface, ItemListFacade |
||
59 | { |
||
60 | /** |
||
61 | * Application item |
||
62 | * |
||
63 | * @var ApplicationItemInterface |
||
64 | */ |
||
65 | protected $item; |
||
66 | |||
67 | /** |
||
68 | * @var ItemList |
||
69 | */ |
||
70 | private $itemList; |
||
71 | |||
72 | 16 | /** |
|
73 | * Item constructor |
||
74 | 16 | * |
|
75 | 16 | * @param ApplicationItemInterface $item Application item |
|
76 | 16 | */ |
|
77 | public function __construct(ApplicationItemInterface $item) |
||
82 | |||
83 | /** |
||
84 | * Get the first value of an item property |
||
85 | * |
||
86 | 2 | * @param string $name Item property name |
|
87 | * |
||
88 | 2 | * @return ValueInterface|ValueInterface[]|array|ItemInterface First value of an item property |
|
89 | * @api |
||
90 | */ |
||
91 | public function __get($name) |
||
95 | |||
96 | /** |
||
97 | * Get a single property (value) |
||
98 | * |
||
99 | * @param string|\stdClass|Iri $name Property name |
||
100 | * @param string $profile Property profile |
||
101 | * @param int|null $index Property value index |
||
102 | * |
||
103 | 7 | * @return ValueInterface|ValueInterface[]|array|ItemInterface Property value(s) |
|
104 | * @throws OutOfBoundsException If the property name is unknown |
||
105 | * @throws OutOfBoundsException If the property value index is out of bounds |
||
106 | 7 | * @api |
|
107 | 4 | */ |
|
108 | 4 | public function getProperty($name, $profile = null, $index = null) |
|
120 | |||
121 | /** |
||
122 | * Return a particular property index |
||
123 | * |
||
124 | 6 | * @param ValueInterface[] $propertyValues Property values |
|
125 | * @param int $index Property value index |
||
126 | * |
||
127 | 6 | * @return ValueInterface|ItemInterface |
|
128 | 1 | */ |
|
129 | 1 | protected function getPropertyIndex(array $propertyValues, $index) |
|
141 | |||
142 | /** |
||
143 | * Prepare a property value for returning it |
||
144 | 7 | * |
|
145 | * @param ValueInterface $value Property value |
||
146 | 7 | * |
|
147 | 7 | * @return ValueInterface|ItemInterface Returnable property value |
|
148 | */ |
||
149 | protected function getPropertyValue(ValueInterface $value) |
||
154 | |||
155 | /** |
||
156 | * Return whether the item is of a particular type (or contained in a list of types) |
||
157 | * |
||
158 | * The item type(s) can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() |
||
159 | * |
||
160 | 5 | * @param array ...$types Item types |
|
161 | * |
||
162 | * @return boolean Item type is contained in the list of types |
||
163 | 5 | * @api |
|
164 | 5 | */ |
|
165 | public function isOfType(...$types) |
||
182 | |||
183 | /** |
||
184 | * Return whether an aliased item type is contained in a set of query types |
||
185 | * |
||
186 | * @param string $profile Type profile |
||
187 | 5 | * @param array $names Aliased type names |
|
188 | * @param ProfiledNamesList $types Query types |
||
189 | * |
||
190 | * @return bool Item type is contained in the set of query types |
||
191 | 5 | */ |
|
192 | 5 | protected function isOfProfiledTypes($profile, array $names, ProfiledNamesList $types) |
|
204 | |||
205 | /** |
||
206 | * Test whether a type is contained in a list of names |
||
207 | * |
||
208 | * @param \stdClass $type Type |
||
209 | 5 | * @param string $profile Type profile |
|
210 | * @param array $names Aliased type names |
||
211 | 5 | * |
|
212 | 5 | * @return bool Type is contained in names list |
|
213 | */ |
||
214 | protected function isTypeInNames($type, $profile, array $names) |
||
219 | |||
220 | /** |
||
221 | * Get all values of the first available property in a stack |
||
222 | * |
||
223 | * The property stack can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() |
||
224 | * |
||
225 | * @param array $properties Properties |
||
226 | * |
||
227 | 2 | * @return ValueInterface[]|array Property values |
|
228 | * @throws InvalidArgumentException If no property name was given |
||
229 | * @throws OutOfBoundsException If none of the requested properties is known |
||
230 | 2 | * @api |
|
231 | */ |
||
232 | public function getFirstProperty(...$properties) |
||
254 | |||
255 | /** |
||
256 | 1 | * Return all properties |
|
257 | * |
||
258 | 1 | * @return PropertyListInterface Properties |
|
259 | 1 | * @api |
|
260 | 1 | */ |
|
261 | public function getProperties() |
||
270 | |||
271 | /** |
||
272 | 2 | * Return an object representation of the item |
|
273 | * |
||
274 | 2 | * @return \stdClass Micro information item |
|
275 | * @api |
||
276 | */ |
||
277 | public function toObject() |
||
281 | |||
282 | /** |
||
283 | 1 | * Get the item type |
|
284 | * |
||
285 | 1 | * @return \stdClass[] Item type |
|
286 | * @api |
||
287 | */ |
||
288 | public function getType() |
||
292 | |||
293 | /** |
||
294 | 1 | * Get the item format |
|
295 | * |
||
296 | 1 | * @return int Item format |
|
297 | * @api |
||
298 | */ |
||
299 | public function getFormat() |
||
303 | |||
304 | /** |
||
305 | 1 | * Get the item ID |
|
306 | * |
||
307 | 1 | * @return string Item ID |
|
308 | * @api |
||
309 | */ |
||
310 | public function getId() |
||
314 | |||
315 | /** |
||
316 | 1 | * Get the item language |
|
317 | * |
||
318 | 1 | * @return string Item language |
|
319 | * @api |
||
320 | */ |
||
321 | public function getLanguage() |
||
325 | |||
326 | /** |
||
327 | 1 | * Return the item value |
|
328 | * |
||
329 | 1 | * @return string Item value |
|
330 | * @api |
||
331 | */ |
||
332 | public function getValue() |
||
336 | |||
337 | /** |
||
338 | * Filter the items by item type(s). |
||
339 | * |
||
340 | * @param array ...$types Item types |
||
341 | * |
||
342 | * @return ItemInterface[] Items matching the requested types |
||
343 | */ |
||
344 | public function getItems(...$types) |
||
348 | |||
349 | /** |
||
350 | * Return the first item, optionally of particular types. |
||
351 | * |
||
352 | * @param array ...$types Item types |
||
353 | * |
||
354 | * @return ItemInterface Item |
||
355 | */ |
||
356 | public function getFirstItem(...$types) |
||
360 | |||
361 | /** |
||
362 | * Count the elements in the item list. |
||
363 | * |
||
364 | * @return int |
||
365 | */ |
||
366 | public function count() |
||
370 | } |
||
371 |