NodeVariable::getNode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * @license     http://opensource.org/licenses/mit-license.php MIT
5
 * @link        https://github.com/nicoSWD
6
 * @author      Nicolas Oelgart <[email protected]>
7
 */
8
namespace nicoSWD\Rule\TokenStream\Node;
9
10
use nicoSWD\Rule\TokenStream\Token\BaseToken;
11
12
final class NodeVariable extends BaseNode
13
{
14 140
    public function getNode(): BaseToken
15
    {
16 140
        $token = $this->tokenStream->getVariable($this->getVariableName());
17
18 136
        while ($this->hasMethodCall()) {
19 82
            $token = $this->getMethod($token)->call(...$this->getArguments());
20
        }
21
22 102
        return $token;
23
    }
24
25 140
    private function getVariableName(): string
26
    {
27 140
        return $this->getCurrentNode()->getOriginalValue();
28
    }
29
}
30