| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Edm\Annotation; |
| 6: | |
| 7: | use LaravelUi5\OData\Edm\Contracts\Annotation\PropertyValueInterface; |
| 8: | use LaravelUi5\OData\Edm\Contracts\Annotation\RecordAnnotationValueInterface; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | final readonly class RecordAnnotationValue implements RecordAnnotationValueInterface |
| 21: | { |
| 22: | |
| 23: | private array $propertyValues; |
| 24: | |
| 25: | public function __construct( |
| 26: | private ?string $type = null, |
| 27: | PropertyValueInterface ...$propertyValues, |
| 28: | ) { |
| 29: | $this->propertyValues = array_values($propertyValues); |
| 30: | } |
| 31: | |
| 32: | public function getType(): ?string |
| 33: | { |
| 34: | return $this->type; |
| 35: | } |
| 36: | |
| 37: | |
| 38: | public function getPropertyValues(): array |
| 39: | { |
| 40: | return $this->propertyValues; |
| 41: | } |
| 42: | |
| 43: | public function getPropertyValue(string $name): ?PropertyValueInterface |
| 44: | { |
| 45: | foreach ($this->propertyValues as $pv) { |
| 46: | if ($pv->getProperty() === $name) { |
| 47: | return $pv; |
| 48: | } |
| 49: | } |
| 50: | return null; |
| 51: | } |
| 52: | } |
| 53: | |