1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData\Edm\Annotation;
6:
7: use LaravelUi5\OData\Edm\Contracts\Annotation\AnnotationValueInterface;
8: use LaravelUi5\OData\Edm\Contracts\Annotation\CollectionAnnotationValueInterface;
9:
10: /**
11: * A collection annotation value — an ordered list of annotation values.
12: *
13: * Accepts zero or more AnnotationValueInterface instances as variadic
14: * arguments. Document order is preserved.
15: *
16: * @see CollectionAnnotationValueInterface
17: * @see OData CSDL XML v4.01 §14.4.6 (Collection)
18: */
19: final readonly class CollectionAnnotationValue implements CollectionAnnotationValueInterface
20: {
21: /** @var list<AnnotationValueInterface> */
22: private array $items;
23:
24: public function __construct(AnnotationValueInterface ...$items)
25: {
26: $this->items = array_values($items);
27: }
28:
29: /** @return list<AnnotationValueInterface> */
30: public function getItems(): array
31: {
32: return $this->items;
33: }
34:
35: public function isEmpty(): bool
36: {
37: return $this->items === [];
38: }
39:
40: public function count(): int
41: {
42: return count($this->items);
43: }
44: }
45: