Total Complexity | 2 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class FragmentDefinitionWriter extends AbstractWriter |
||
10 | { |
||
11 | /** |
||
12 | * @param NodeInterface|FragmentDefinitionNode $node |
||
13 | * @inheritdoc |
||
14 | */ |
||
15 | public function write(NodeInterface $node): string |
||
16 | { |
||
17 | $name = $this->printNode($node->getName()); |
||
18 | $typeCondition = $this->printNode($node->getTypeCondition()); |
||
19 | $variableDefinitions = $this->printNodes($node->getVariableDefinitions()); |
||
20 | $directives = $this->printNodes($node->getDirectives()); |
||
21 | $selectionSet = $this->printNode($node->getSelectionSet()); |
||
22 | |||
23 | // Note: fragment variable definitions are experimental and may be changed |
||
24 | // or removed in the future. |
||
25 | return implode(' ', [ |
||
26 | 'fragment ' . $name . wrap('(', implode(', ', $variableDefinitions), ')'), |
||
27 | 'on ' . $typeCondition . ' ' . implode(' ', $directives), |
||
28 | $selectionSet |
||
29 | ]); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @inheritdoc |
||
34 | */ |
||
35 | public function supportsWriter(NodeInterface $node): bool |
||
38 | } |
||
39 | } |
||
40 |