1 | <?php |
||
58 | class Item extends ItemList implements ItemInterface |
||
59 | { |
||
60 | /** |
||
61 | * Application item |
||
62 | * |
||
63 | * @var ApplicationItemInterface |
||
64 | */ |
||
65 | protected $item; |
||
66 | |||
67 | /** |
||
68 | * Item constructor |
||
69 | * |
||
70 | * @param ApplicationItemInterface $item Application item |
||
71 | */ |
||
72 | 14 | public function __construct(ApplicationItemInterface $item) |
|
77 | |||
78 | /** |
||
79 | * Get the first value of an item property |
||
80 | * |
||
81 | * @param string $name Item property name |
||
82 | * @return ValueInterface|ValueInterface[]|array|ItemInterface First value of an item property |
||
83 | * @api |
||
84 | */ |
||
85 | 2 | public function __get($name) |
|
89 | |||
90 | /** |
||
91 | * Get a single property (value) |
||
92 | * |
||
93 | * @param string|\stdClass|Iri $name Property name |
||
94 | * @param string $profile Property profile |
||
95 | * @param int|null $index Property value index |
||
96 | * @return ValueInterface|ValueInterface[]|array|ItemInterface Property value(s) |
||
97 | * @throws OutOfBoundsException If the property name is unknown |
||
98 | * @throws OutOfBoundsException If the property value index is out of bounds |
||
99 | * @api |
||
100 | */ |
||
101 | 7 | public function getProperty($name, $profile = null, $index = null) |
|
113 | |||
114 | /** |
||
115 | * Return a particular property index |
||
116 | * |
||
117 | * @param ValueInterface[] $propertyValues Property values |
||
118 | * @param int $index Property value index |
||
119 | * @return ValueInterface|ItemInterface |
||
120 | */ |
||
121 | 6 | protected function getPropertyIndex(array $propertyValues, $index) |
|
133 | |||
134 | /** |
||
135 | * Prepare a property value for returning it |
||
136 | * |
||
137 | * @param ValueInterface $value Property value |
||
138 | * @return ValueInterface|ItemInterface Returnable property value |
||
139 | */ |
||
140 | 7 | protected function getPropertyValue(ValueInterface $value) |
|
145 | |||
146 | /** |
||
147 | * Return whether the item is of a particular type (or contained in a list of types) |
||
148 | * |
||
149 | * The item type(s) can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() |
||
150 | * |
||
151 | * @param array ...$types Item types |
||
152 | * @return boolean Item type is contained in the list of types |
||
153 | * @api |
||
154 | */ |
||
155 | 5 | public function isOfType(...$types) |
|
172 | |||
173 | /** |
||
174 | * Return whether an aliased item type is contained in a set of query types |
||
175 | * |
||
176 | * @param string $profile Type profile |
||
177 | * @param array $names Aliased type names |
||
178 | * @param ProfiledNamesList $types Query types |
||
179 | * @return bool Item type is contained in the set of query types |
||
180 | */ |
||
181 | 5 | protected function isOfProfiledTypes($profile, array $names, ProfiledNamesList $types) |
|
192 | |||
193 | /** |
||
194 | * Test whether a type is contained in a list of names |
||
195 | * |
||
196 | * @param \stdClass $type Type |
||
197 | * @param string $profile Type profile |
||
198 | * @param array $names Aliased type names |
||
199 | * @return bool Type is contained in names list |
||
200 | */ |
||
201 | 5 | protected function isTypeInNames($type, $profile, array $names) |
|
206 | |||
207 | /** |
||
208 | * Get all values of the first available property in a stack |
||
209 | * |
||
210 | * The property stack can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() |
||
211 | * |
||
212 | * @param string $name Name |
||
213 | * @param string $profile Profile |
||
214 | * @return ValueInterface[]|array Property values |
||
215 | * @throws InvalidArgumentException If no property name was given |
||
216 | * @throws OutOfBoundsException If none of the requested properties is known |
||
217 | * @api |
||
218 | */ |
||
219 | 2 | public function getFirstProperty($name, $profile = null) |
|
241 | |||
242 | /** |
||
243 | * Return all properties |
||
244 | * |
||
245 | * @return PropertyListInterface Properties |
||
246 | * @api |
||
247 | */ |
||
248 | 1 | public function getProperties() |
|
256 | |||
257 | /** |
||
258 | * Return an object representation of the item |
||
259 | * |
||
260 | * @return \stdClass Micro information item |
||
261 | * @api |
||
262 | */ |
||
263 | 2 | public function toObject() |
|
267 | |||
268 | /** |
||
269 | * Get the item type |
||
270 | * |
||
271 | * @return \stdClass[] Item type |
||
272 | */ |
||
273 | 1 | public function getType() |
|
277 | |||
278 | /** |
||
279 | * Get the item format |
||
280 | * |
||
281 | * @return int Item format |
||
282 | */ |
||
283 | 1 | public function getFormat() |
|
287 | |||
288 | /** |
||
289 | * Get the item ID |
||
290 | * |
||
291 | * @return string Item ID |
||
292 | */ |
||
293 | 1 | public function getId() |
|
297 | |||
298 | /** |
||
299 | * Get the item language |
||
300 | * |
||
301 | * @return string Item language |
||
302 | */ |
||
303 | 1 | public function getLanguage() |
|
307 | |||
308 | /** |
||
309 | * Return the item value |
||
310 | * |
||
311 | * @return string Item value |
||
312 | */ |
||
313 | 1 | public function getValue() |
|
317 | } |
||
318 |