1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData\Edm\Property;
6:
7: use LaravelUi5\OData\Edm\Contracts\Annotation\AnnotationInterface;
8: use LaravelUi5\OData\Edm\Contracts\Property\NavigationPropertyInterface;
9: use LaravelUi5\OData\Edm\Contracts\Type\EntityTypeInterface;
10: use LaravelUi5\OData\Edm\HasAnnotations;
11:
12: final readonly class NavigationProperty implements NavigationPropertyInterface
13: {
14: use HasAnnotations;
15:
16: /**
17: * @param array<string, string> $referentialConstraints dependent → principal property names
18: * @param list<AnnotationInterface> $annotations
19: */
20: public function __construct(
21: private string $name,
22: private EntityTypeInterface $targetType,
23: private bool $isCollection = true,
24: private bool $isNullable = true,
25: private ?string $partnerName = null,
26: private bool $isContainmentTarget = false,
27: private array $referentialConstraints = [],
28: private ?string $onDeleteAction = null,
29: array $annotations = [],
30: ) {
31: $this->annotations = $annotations;
32: }
33:
34: public function getName(): string
35: {
36: return $this->name;
37: }
38:
39: public function getTargetType(): EntityTypeInterface
40: {
41: return $this->targetType;
42: }
43:
44: public function isCollection(): bool
45: {
46: return $this->isCollection;
47: }
48:
49: public function isNullable(): bool
50: {
51: return $this->isNullable;
52: }
53:
54: public function getPartnerName(): ?string
55: {
56: return $this->partnerName;
57: }
58:
59: public function isContainmentTarget(): bool
60: {
61: return $this->isContainmentTarget;
62: }
63:
64: public function getReferentialConstraints(): array
65: {
66: return $this->referentialConstraints;
67: }
68:
69: public function getOnDeleteAction(): ?string
70: {
71: return $this->onDeleteAction;
72: }
73: }
74: