Group   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 30
ccs 15
cts 15
cp 1
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accept() 0 3 1
A visit() 0 21 5
1
<?php declare(strict_types = 1);
2
3
namespace Apicart\FQL\Generator\SQL;
4
5
use Apicart\FQL\Generator\Common\AbstractVisitor;
6
use Apicart\FQL\Token\Node\Group as GroupNode;
7
use Apicart\FQL\Value\AbstractNode;
8
9
final class Group extends AbstractVisitor
10
{
11
12 1
    public function accept(AbstractNode $node): bool
13
    {
14 1
        return $node instanceof GroupNode;
15
    }
16
17
18 1
    public function visit(AbstractNode $node, ?AbstractVisitor $subVisitor = null, ?array $options = null): string
19
    {
20
        /** @var GroupNode $groupNode */
21 1
        $groupNode = $node;
22
23 1
        $clauses = [];
24 1
        foreach ($groupNode->getNodes() as $subNode) {
25 1
            $options['parent'] = $node;
26 1
            if ($subVisitor !== null) {
27 1
                $clauses[] = $subVisitor->visit($subNode, $subVisitor, $options);
28
            }
29
        }
30
31 1
        $clauses = implode(' ', $clauses);
32 1
        $tokenLeft = $groupNode->getTokenLeft();
33 1
        $tokenRight = $groupNode->getTokenRight();
34
35 1
        $delimiter = $tokenLeft === null ? '' : $tokenLeft->getDelimiter();
36 1
        $lexeme = $tokenRight === null ? '' : $tokenRight->getLexeme();
37
38 1
        return "{$delimiter}{$clauses}{$lexeme}";
39
    }
40
41
}
42