Passed
Push — master ( 44542b...077e9d )
by Tomáš
03:58
created

Group::visit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 3
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 2
rs 10
c 0
b 0
f 0
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
            $clauses[] = $subVisitor->visit($subNode, $subVisitor, $options);
0 ignored issues
show
Bug introduced by
The method visit() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
            /** @scrutinizer ignore-call */ 
27
            $clauses[] = $subVisitor->visit($subNode, $subVisitor, $options);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        }
28
29 1
        $clauses = implode(' ', $clauses);
30
31 1
        return "{$groupNode->getTokenLeft()->getDelimiter()}{$clauses}{$groupNode->getTokenRight()->getLexeme()}";
32
    }
33
34
}
35