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

TokenResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 30
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 14 3
A info() 0 4 1
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