1 | <?php |
||
24 | class Backend |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private const ERR_UNSUPPORTED_RULE = '%s is not supported by this compiler'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private const ERR_UNRECOGNIZED_RULE = 'The language rule <%s> is not supported or implemented by this compiler'; |
||
35 | |||
36 | /** |
||
37 | * @var string[] |
||
38 | */ |
||
39 | private const BUILDERS = [ |
||
40 | // Root definitions |
||
41 | 'SchemaDefinition' => Definition\SchemaBuilder::class, |
||
42 | 'ObjectDefinition' => Definition\ObjectBuilder::class, |
||
43 | 'EnumDefinition' => Definition\EnumBuilder::class, |
||
44 | 'ScalarDefinition' => Definition\ScalarBuilder::class, |
||
45 | 'InputDefinition' => Definition\InputBuilder::class, |
||
46 | 'DirectiveDefinition' => Definition\DirectiveBuilder::class, |
||
47 | 'InterfaceDefinition' => Definition\InterfaceBuilder::class, |
||
48 | 'UnionDefinition' => Definition\UnionBuilder::class, |
||
49 | // Invocations |
||
50 | 'Directive' => Invocation\DirectiveBuilder::class, |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * @var string[] |
||
55 | */ |
||
56 | private const UNSUPPORTED_BUILDERS = [ |
||
57 | 'QueryOperation' => 'Query expression', |
||
58 | 'MutationOperation' => 'Mutation expression', |
||
59 | 'SubscriptionOperation' => 'Subscription expression', |
||
60 | 'FragmentDefinition' => 'Fragment definition', |
||
61 | ]; |
||
62 | |||
63 | /** |
||
64 | * @var Process |
||
65 | */ |
||
66 | private $process; |
||
67 | |||
68 | /** |
||
69 | * Backend constructor. |
||
70 | * @param Process $process |
||
71 | */ |
||
72 | public function __construct(Process $process) |
||
76 | |||
77 | /** |
||
78 | * @param Document $document |
||
79 | * @return Context |
||
80 | */ |
||
81 | public function context(Document $document): Context |
||
85 | |||
86 | /** |
||
87 | * @param Context $context |
||
88 | * @param RuleInterface $ast |
||
89 | * @return Document |
||
90 | * @throws TypeException |
||
91 | */ |
||
92 | public function each(Context $context, RuleInterface $ast): Document |
||
105 | |||
106 | /** |
||
107 | * @param Context $context |
||
108 | * @param RuleInterface $ast |
||
109 | * @return DefinitionInterface |
||
110 | * @throws TypeException |
||
111 | */ |
||
112 | public function exec(Context $context, RuleInterface $ast): DefinitionInterface |
||
130 | |||
131 | /** |
||
132 | * @param BuilderInterface $builder |
||
133 | * @return DefinitionInterface |
||
134 | */ |
||
135 | private function execBuilder(BuilderInterface $builder): DefinitionInterface |
||
139 | } |
||
140 |