| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | namespace LaravelUi5\OData\Edm; |
| 6: | |
| 7: | use LaravelUi5\OData\Edm\Contracts\Annotation\AnnotationInterface; |
| 8: | use LaravelUi5\OData\Edm\Contracts\EntitySetPathInterface; |
| 9: | use LaravelUi5\OData\Edm\Contracts\FunctionInterface; |
| 10: | use LaravelUi5\OData\Edm\Contracts\FunctionParameterInterface; |
| 11: | use LaravelUi5\OData\Edm\Contracts\Type\TypeInterface; |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | final readonly class EdmFunction implements FunctionInterface |
| 19: | { |
| 20: | use HasAnnotations; |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | public function __construct( |
| 27: | private string $name, |
| 28: | private bool $isBound = false, |
| 29: | private bool $isComposable = false, |
| 30: | private ?TypeInterface $returnType = null, |
| 31: | private bool $returnsCollection = false, |
| 32: | private bool $isReturnTypeNullable = true, |
| 33: | private array $parameters = [], |
| 34: | private ?EntitySetPathInterface $entitySetPath = null, |
| 35: | array $annotations = [], |
| 36: | ) { |
| 37: | $this->annotations = $annotations; |
| 38: | } |
| 39: | |
| 40: | public function getName(): string |
| 41: | { |
| 42: | return $this->name; |
| 43: | } |
| 44: | |
| 45: | public function isBound(): bool |
| 46: | { |
| 47: | return $this->isBound; |
| 48: | } |
| 49: | |
| 50: | public function isComposable(): bool |
| 51: | { |
| 52: | return $this->isComposable; |
| 53: | } |
| 54: | |
| 55: | public function getReturnType(): ?TypeInterface |
| 56: | { |
| 57: | return $this->returnType; |
| 58: | } |
| 59: | |
| 60: | public function returnsCollection(): bool |
| 61: | { |
| 62: | return $this->returnsCollection; |
| 63: | } |
| 64: | |
| 65: | public function isReturnTypeNullable(): bool |
| 66: | { |
| 67: | return $this->isReturnTypeNullable; |
| 68: | } |
| 69: | |
| 70: | public function getParameters(): array |
| 71: | { |
| 72: | return $this->parameters; |
| 73: | } |
| 74: | |
| 75: | public function getParameter(string $name): ?FunctionParameterInterface |
| 76: | { |
| 77: | foreach ($this->parameters as $parameter) { |
| 78: | if ($parameter->getName() === $name) { |
| 79: | return $parameter; |
| 80: | } |
| 81: | } |
| 82: | return null; |
| 83: | } |
| 84: | |
| 85: | public function getEntitySetPath(): ?EntitySetPathInterface |
| 86: | { |
| 87: | return $this->entitySetPath; |
| 88: | } |
| 89: | } |
| 90: | |