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\Context; |
||
| 13 | |||
| 14 | use GraphQL\Contracts\TypeSystem\DirectiveInterface; |
||
| 15 | use Railt\SDL\Frontend\Ast\Definition\DirectiveDefinitionLocationNode as LocationNode; |
||
| 16 | use Railt\SDL\Frontend\Ast\Definition\DirectiveDefinitionNode; |
||
| 17 | use Railt\TypeSystem\Directive; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @property-read DirectiveDefinitionNode $ast |
||
| 21 | */ |
||
| 22 | final class DirectiveDefinitionLocator extends DefinitionLocator |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @param array $args |
||
| 26 | * @return DirectiveInterface |
||
| 27 | * @throws \Throwable |
||
| 28 | */ |
||
| 29 | public function build(array $args): DirectiveInterface |
||
| 30 | { |
||
| 31 | $locations = \array_map(fn(LocationNode $loc): string => $loc->name->value, $this->ast->locations); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 32 | |||
| 33 | return new Directive($this->getName(), [ |
||
| 34 | 'description' => $this->description($this->ast), |
||
| 35 | 'repeatable' => $this->ast->repeatable !== null, |
||
| 36 | 'locations' => $locations, |
||
| 37 | ]); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return string |
||
| 42 | */ |
||
| 43 | public function getName(): string |
||
| 44 | { |
||
| 45 | return $this->ast->name->value; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return array |
||
| 50 | */ |
||
| 51 | public function getGenericArguments(): array |
||
| 52 | { |
||
| 53 | return []; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |