1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData\Edm\Container;
6:
7: use LaravelUi5\OData\Edm\Contracts\Annotation\AnnotationInterface;
8: use LaravelUi5\OData\Edm\Contracts\Container\EntitySetInterface;
9: use LaravelUi5\OData\Edm\Contracts\Container\NavigationPropertyBindingInterface;
10: use LaravelUi5\OData\Edm\Contracts\Type\EntityTypeInterface;
11: use LaravelUi5\OData\Edm\HasAnnotations;
12:
13: final readonly class EntitySet implements EntitySetInterface
14: {
15: use HasAnnotations;
16:
17: /**
18: * @param list<NavigationPropertyBindingInterface> $navigationPropertyBindings
19: * @param list<AnnotationInterface> $annotations
20: */
21: public function __construct(
22: private string $name,
23: private EntityTypeInterface $entityType,
24: private bool $includedInServiceDocument = true,
25: private array $navigationPropertyBindings = [],
26: array $annotations = [],
27: ) {
28: $this->annotations = $annotations;
29: }
30:
31: public function getName(): string
32: {
33: return $this->name;
34: }
35:
36: public function getEntityType(): EntityTypeInterface
37: {
38: return $this->entityType;
39: }
40:
41: public function isIncludedInServiceDocument(): bool
42: {
43: return $this->includedInServiceDocument;
44: }
45:
46: public function getNavigationPropertyBindings(): array
47: {
48: return $this->navigationPropertyBindings;
49: }
50:
51: public function getNavigationPropertyBinding(string $path): ?NavigationPropertyBindingInterface
52: {
53: foreach ($this->navigationPropertyBindings as $binding) {
54: if ($binding->getPath() === $path) {
55: return $binding;
56: }
57: }
58: return null;
59: }
60: }
61: