| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Edm; |
| 6: | |
| 7: | use LaravelUi5\OData\Edm\Contracts\Container\EntityContainerInterface; |
| 8: | use LaravelUi5\OData\Edm\Contracts\EdmxInterface; |
| 9: | use LaravelUi5\OData\Edm\Contracts\ReferenceInterface; |
| 10: | use LaravelUi5\OData\Edm\Contracts\SchemaInterface; |
| 11: | |
| 12: | final readonly class Edmx implements EdmxInterface |
| 13: | { |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | public function __construct( |
| 19: | private string $version, |
| 20: | private array $references, |
| 21: | private array $schemas, |
| 22: | private EntityContainerInterface $entityContainer, |
| 23: | ) {} |
| 24: | |
| 25: | public function getVersion(): string |
| 26: | { |
| 27: | return $this->version; |
| 28: | } |
| 29: | |
| 30: | public function getReferences(): array |
| 31: | { |
| 32: | return $this->references; |
| 33: | } |
| 34: | |
| 35: | public function getReference(string $uri): ?ReferenceInterface |
| 36: | { |
| 37: | foreach ($this->references as $reference) { |
| 38: | if ($reference->getUri() === $uri) { |
| 39: | return $reference; |
| 40: | } |
| 41: | } |
| 42: | return null; |
| 43: | } |
| 44: | |
| 45: | public function getSchemas(): array |
| 46: | { |
| 47: | return $this->schemas; |
| 48: | } |
| 49: | |
| 50: | public function getSchema(string $namespace): ?SchemaInterface |
| 51: | { |
| 52: | return $this->schemas[$namespace] ?? null; |
| 53: | } |
| 54: | |
| 55: | public function getEntityContainer(): EntityContainerInterface |
| 56: | { |
| 57: | return $this->entityContainer; |
| 58: | } |
| 59: | } |
| 60: | |