Tag::accept()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
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