Conditions | 8 |
Paths | 34 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 8.1515 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
19 | 23 | public function visit(AbstractNode $node, ?AbstractVisitor $subVisitor = null, ?array $options = null): string |
|
20 | { |
||
21 | 23 | if (! $node instanceof GroupNode) { |
|
22 | throw new LogicException('Implementation accepts instance of Group Node'); |
||
23 | } |
||
24 | 23 | if ($subVisitor === null) { |
|
25 | throw new LogicException('Implementation requires sub-visitor'); |
||
26 | } |
||
27 | 23 | $clauses = []; |
|
28 | 23 | foreach ($node->getNodes() as $subNode) { |
|
29 | 23 | $clauses[] = $subVisitor->visit($subNode, $subVisitor, $options); |
|
30 | } |
||
31 | 23 | $clauses = implode(' ', $clauses); |
|
32 | 23 | $tokenLeft = $node->getTokenLeft(); |
|
33 | 23 | $tokenRight = $node->getTokenRight(); |
|
34 | |||
35 | 23 | $domainPrefix = $tokenLeft === null || $tokenLeft->getDomain() === '' ? '' : "{$tokenLeft->getDomain()}:"; |
|
36 | 23 | $delimiter = $tokenLeft === null ? '' : $tokenLeft->getDelimiter(); |
|
37 | 23 | $lexeme = $tokenRight === null ? '' : $tokenRight->getLexeme(); |
|
38 | |||
39 | 23 | return "{$domainPrefix}{$delimiter}{$clauses}{$lexeme}"; |
|
40 | } |
||
43 |