Completed
Push — nln-php7 ( 6680df...1a6b54 )
by Nicolas
02:06
created

VariableProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Karma\Generator;
6
7
use Karma\Configuration\FileParser;
8
use Karma\Generator\NameTranslators\NullTranslator;
9
10
class VariableProvider
11
{
12
    private FileParser
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
13
        $parser;
14
    private NameTranslator
15
        $nameTranslator;
16
17 16
    public function __construct(FileParser $parser)
18
    {
19 16
        $this->parser = $parser;
20 16
        $this->nameTranslator = new NullTranslator();
21 16
    }
22
23 12
    public function setNameTranslator(NameTranslator $translator)
24
    {
25 12
        $this->nameTranslator = $translator;
26
27 12
        return $this;
28
    }
29
30 15
    public function getAllVariables()
31
    {
32 15
        $parsedVariables = $this->parser->getVariables();
33
34 15
        $variables = array();
35
36 15
        foreach($parsedVariables as $variable => $info)
37
        {
38 15
            $variables[$variable] = $this->nameTranslator->translate($info['file'], $variable);
39
        }
40
41 15
        return $variables;
42
    }
43
}
44