railt /
sdl
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of Railt package. |
||
| 5 | * |
||
| 6 | * For the full copyright and license information, please view the LICENSE |
||
| 7 | * file that was distributed with this source code. |
||
| 8 | */ |
||
| 9 | |||
| 10 | declare(strict_types=1); |
||
| 11 | |||
| 12 | namespace Railt\SDL\Backend\Runtime; |
||
| 13 | |||
| 14 | use GraphQL\Contracts\TypeSystem\DefinitionInterface; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Class Execution |
||
| 18 | */ |
||
| 19 | abstract class Execution implements ExecutionInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var DefinitionInterface |
||
| 23 | */ |
||
| 24 | private DefinitionInterface $context; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var iterable |
||
| 28 | */ |
||
| 29 | private iterable $arguments; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Execution constructor. |
||
| 33 | * |
||
| 34 | * @param DefinitionInterface $context |
||
| 35 | * @param iterable|\Traversable|array $arguments |
||
| 36 | */ |
||
| 37 | public function __construct(DefinitionInterface $context, iterable $arguments = []) |
||
| 38 | { |
||
| 39 | $this->context = $context; |
||
| 40 | |||
| 41 | foreach ($arguments as $name => $value) { |
||
| 42 | $this->arguments[$name] = $value; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return DefinitionInterface |
||
| 48 | */ |
||
| 49 | public function getContext(): DefinitionInterface |
||
| 50 | { |
||
| 51 | return $this->context; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return iterable |
||
| 56 | */ |
||
| 57 | public function getArguments(): iterable |
||
| 58 | { |
||
| 59 | return $this->arguments; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param string $name |
||
| 64 | * @return mixed|null |
||
| 65 | */ |
||
| 66 | public function getArgument(string $name) |
||
| 67 | { |
||
| 68 | return $this->arguments[$name] ?? null; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param string $name |
||
| 73 | * @return bool |
||
| 74 | */ |
||
| 75 | public function hasArgument(string $name): bool |
||
| 76 | { |
||
| 77 | return isset($this->arguments[$name]) || \array_key_exists($name, $this->arguments); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 78 | } |
||
| 79 | } |
||
| 80 |