Completed
Push — master ( 69b695...671bd7 )
by Kirill
06:49
created

TokenResolver::resolve()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 2
crap 12
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Compiler\Grammar\PP2;
11
12
use Railt\Compiler\Reader\BaseTokens;
13
use Railt\Io\Readable;
14
use Railt\Lexer\TokenInterface;
15
16
/**
17
 * Class TokenResolver
18
 */
19
class TokenResolver extends BaseTokens implements ResolverInterface
20
{
21
    /**
22
     * @param Readable $readable
23
     * @param TokenInterface $token
24
     */
25
    public function resolve(Readable $readable, TokenInterface $token): void
26
    {
27
        [$name, $value, $group] = $this->info($token);
0 ignored issues
show
Bug introduced by
The variable $name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $value does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $group does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
28
29
        $this->setToken($name, $value);
30
31
        if ($group !== null) {
32
            $this->setGroup($name, (int)$group);
33
        }
34
35
        if ($token->name() === 'T_SKIP') {
36
            $this->makeSkipped($name);
37
        }
38
    }
39
40
    /**
41
     * @param TokenInterface $token
42
     * @return array
43
     */
44
    private function info(TokenInterface $token): array
45
    {
46
        return [$token->value(1), $token->value(2), $token->value(3)];
47
    }
48
}
49