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 array|string|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 $index Property value index |
||
96 | * @return array|string|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) |
|
124 | |||
125 | /** |
||
126 | * Prepare a property value for returning it |
||
127 | * |
||
128 | * @param ValueInterface $value Property value |
||
129 | * @return Item|mixed Returnable property value |
||
130 | */ |
||
131 | 7 | protected function getPropertyValue(ValueInterface $value) |
|
132 | { |
||
133 | 7 | return ($value instanceof ApplicationItemInterface) ? |
|
134 | 7 | ItemFactory::createFromApplicationItem($value) : $value; |
|
135 | } |
||
136 | |||
137 | /** |
||
138 | * Return whether the item is of a particular type (or contained in a list of types) |
||
139 | * |
||
140 | * The item type(s) can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() |
||
141 | * |
||
142 | * @param array ...$types Item types |
||
143 | * @return boolean Item type is contained in the list of types |
||
144 | * @api |
||
145 | */ |
||
146 | 5 | public function isOfType(...$types) |
|
163 | |||
164 | /** |
||
165 | * Return whether an aliased item type in contained in a set of query types |
||
166 | * |
||
167 | * @param string $profile Type profile |
||
168 | * @param array $names Aliased type names |
||
169 | * @param ProfiledNamesList $types Query types |
||
170 | * @return bool Item type is contained in the set of query types |
||
171 | */ |
||
172 | 5 | protected function isOfProfiledTypes($profile, array $names, ProfiledNamesList $types) |
|
185 | |||
186 | /** |
||
187 | * Get all values of the first available property in a stack |
||
188 | * |
||
189 | * The property stack can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() |
||
190 | * |
||
191 | * @param string $name Name |
||
192 | * @param string $profile Profile |
||
193 | * @return array|string|ItemInterface Property values |
||
194 | * @throws InvalidArgumentException If no property name was given |
||
195 | * @throws OutOfBoundsException If none of the requested properties is known |
||
196 | * @api |
||
197 | */ |
||
198 | 2 | public function getFirstProperty($name, $profile = null) |
|
220 | |||
221 | /** |
||
222 | * Return all properties |
||
223 | * |
||
224 | * @return PropertyListInterface Properties |
||
225 | * @api |
||
226 | */ |
||
227 | 1 | public function getProperties() |
|
235 | |||
236 | /** |
||
237 | * Return an object representation of the item |
||
238 | * |
||
239 | * @return \stdClass Micro information item |
||
240 | * @api |
||
241 | */ |
||
242 | 2 | public function toObject() |
|
246 | |||
247 | /** |
||
248 | * Get the item type |
||
249 | * |
||
250 | * @return \stdClass[] Item type |
||
251 | */ |
||
252 | 1 | public function getType() |
|
256 | |||
257 | /** |
||
258 | * Get the item format |
||
259 | * |
||
260 | * @return int Item format |
||
261 | */ |
||
262 | 1 | public function getFormat() |
|
266 | |||
267 | /** |
||
268 | * Get the item ID |
||
269 | * |
||
270 | * @return string Item ID |
||
271 | */ |
||
272 | public function getId() |
||
276 | |||
277 | /** |
||
278 | * Get the item language |
||
279 | * |
||
280 | * @return string Item language |
||
281 | */ |
||
282 | public function getLanguage() |
||
286 | |||
287 | /** |
||
288 | * Return the item value |
||
289 | * |
||
290 | * @return string Item value |
||
291 | */ |
||
292 | public function getValue() |
||
296 | } |
||
297 |