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\NavigationPropertyBindingInterface;
9: use LaravelUi5\OData\Edm\Contracts\Container\SingletonInterface;
10: use LaravelUi5\OData\Edm\Contracts\Type\EntityTypeInterface;
11: use LaravelUi5\OData\Edm\HasAnnotations;
12:
13: final readonly class Singleton implements SingletonInterface
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 array $navigationPropertyBindings = [],
25: array $annotations = [],
26: ) {
27: $this->annotations = $annotations;
28: }
29:
30: public function getName(): string
31: {
32: return $this->name;
33: }
34:
35: public function getEntityType(): EntityTypeInterface
36: {
37: return $this->entityType;
38: }
39:
40: public function getNavigationPropertyBindings(): array
41: {
42: return $this->navigationPropertyBindings;
43: }
44:
45: public function getNavigationPropertyBinding(string $path): ?NavigationPropertyBindingInterface
46: {
47: foreach ($this->navigationPropertyBindings as $binding) {
48: if ($binding->getPath() === $path) {
49: return $binding;
50: }
51: }
52: return null;
53: }
54: }
55: