Tag   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 19
ccs 7
cts 9
cp 0.7778
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A visit() 0 10 3
A accept() 0 3 2
1
<?php declare(strict_types = 1);
2
3
namespace Apicart\FQL\Generator\Native;
4
5
use Apicart\FQL\Generator\Common\AbstractVisitor;
6
use Apicart\FQL\Token\Node\Term;
7
use Apicart\FQL\Token\Token\Tag as TagToken;
8
use Apicart\FQL\Value\AbstractNode;
9
use LogicException;
10
11
final class Tag extends AbstractVisitor
12
{
13
14 133
    public function accept(AbstractNode $node): bool
15
    {
16 133
        return $node instanceof Term && $node->getToken() instanceof TagToken;
17
    }
18
19
20 1
    public function visit(AbstractNode $node, ?AbstractVisitor $subVisitor = null, ?array $options = null): string
21
    {
22 1
        if (! $node instanceof Term) {
23
            throw new LogicException('Implementation accepts instance of Term Node');
24
        }
25 1
        $token = $node->getToken();
26 1
        if (! $token instanceof TagToken) {
27
            throw new LogicException('Implementation accepts instance of Tag Token');
28
        }
29 1
        return "{$token->getMarker()}{$token->getTag()}";
30
    }
31
32
}
33