1 | <?php |
||
58 | class Item extends Collection implements ItemInterface |
||
59 | { |
||
60 | /** |
||
61 | * Application item |
||
62 | * |
||
63 | * @var ApplicationItemInterface |
||
64 | */ |
||
65 | protected $item; |
||
66 | |||
67 | /** |
||
68 | * @var ItemList |
||
69 | */ |
||
70 | private $itemList; |
||
71 | |||
72 | /** |
||
73 | * Item constructor |
||
74 | * |
||
75 | * @param ApplicationItemInterface $item Application item |
||
76 | */ |
||
77 | 22 | public function __construct(ApplicationItemInterface $item) |
|
82 | |||
83 | /** |
||
84 | * Get the first value of an item property |
||
85 | * |
||
86 | * @param string $name Item property name |
||
87 | * |
||
88 | * @return ValueInterface|ValueInterface[]|array|ItemInterface First value of an item property |
||
89 | * @api |
||
90 | */ |
||
91 | 3 | 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 | * @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 | * @api |
||
107 | */ |
||
108 | 8 | public function getProperty($name, $profile = null, $index = null) |
|
120 | |||
121 | /** |
||
122 | * Return a particular property index |
||
123 | * |
||
124 | * @param ValueInterface[] $propertyValues Property values |
||
125 | * @param int $index Property value index |
||
126 | * |
||
127 | * @return ValueInterface|ItemInterface |
||
128 | */ |
||
129 | 7 | protected function getPropertyIndex(array $propertyValues, $index) |
|
141 | |||
142 | /** |
||
143 | * Prepare a property value for returning it |
||
144 | * |
||
145 | * @param ValueInterface $value Property value |
||
146 | * |
||
147 | * @return ValueInterface|ItemInterface Returnable property value |
||
148 | */ |
||
149 | 8 | 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 | * @param array ...$types Item types |
||
161 | * |
||
162 | * @return boolean Item type is contained in the list of types |
||
163 | * @api |
||
164 | */ |
||
165 | 9 | 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 | * @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 | */ |
||
192 | 9 | 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 | * @param string $profile Type profile |
||
210 | * @param array $names Aliased type names |
||
211 | * |
||
212 | * @return bool Type is contained in names list |
||
213 | */ |
||
214 | 9 | 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 | * @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 | * @api |
||
231 | */ |
||
232 | 2 | public function getFirstProperty(...$properties) |
|
254 | |||
255 | /** |
||
256 | * Return all properties |
||
257 | * |
||
258 | * @return PropertyListInterface Properties |
||
259 | * @api |
||
260 | */ |
||
261 | 1 | public function getProperties() |
|
270 | |||
271 | /** |
||
272 | * Return an object representation of the item |
||
273 | * |
||
274 | * @return \stdClass Micro information item |
||
275 | * @api |
||
276 | */ |
||
277 | 2 | public function toObject() |
|
281 | |||
282 | /** |
||
283 | * Get the item type |
||
284 | * |
||
285 | * @return \stdClass[] Item type |
||
286 | * @api |
||
287 | */ |
||
288 | 1 | public function getType() |
|
292 | |||
293 | /** |
||
294 | * Get the item format |
||
295 | * |
||
296 | * @return int Item format |
||
297 | * @api |
||
298 | */ |
||
299 | 1 | public function getFormat() |
|
303 | |||
304 | /** |
||
305 | * Get the item ID |
||
306 | * |
||
307 | * @return string Item ID |
||
308 | * @api |
||
309 | */ |
||
310 | 1 | public function getId() |
|
314 | |||
315 | /** |
||
316 | * Get the item language |
||
317 | * |
||
318 | * @return string Item language |
||
319 | * @api |
||
320 | */ |
||
321 | 1 | public function getLanguage() |
|
325 | |||
326 | /** |
||
327 | * Return the item value |
||
328 | * |
||
329 | * @return string Item value |
||
330 | * @api |
||
331 | */ |
||
332 | 1 | 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 | 5 | 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 | 2 | public function getFirstItem(...$types) |
|
360 | |||
361 | /** |
||
362 | * Count the elements in the item list. |
||
363 | * |
||
364 | * @return int |
||
365 | */ |
||
366 | 1 | public function count() |
|
370 | } |
||
371 |