Conditions | 5 |
Paths | 8 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function write(NodeInterface $node): string |
||
16 | { |
||
17 | $operation = $node->getOperation(); |
||
|
|||
18 | $name = $this->printNode($node->getName()); |
||
19 | $variablesDefinitions = $this->printNodes($node->getVariableDefinitions()); |
||
20 | $directives = $this->printNodes($node->getDirectives()); |
||
21 | $selectionSet = $this->printNode($node->getSelectionSet()); |
||
22 | |||
23 | // Anonymous queries with no directives or variable definitions can use |
||
24 | // the query short form. |
||
25 | return null === $name && empty($directives) && empty($variablesDefinitions) && $operation === 'query' |
||
26 | ? $selectionSet |
||
27 | : implode(' ', [ |
||
28 | $operation, |
||
29 | $name . wrap('(', implode(', ', $variablesDefinitions), ')'), |
||
30 | implode(' ', $directives), |
||
31 | $selectionSet, |
||
32 | ]); |
||
43 |