Completed
Push — master ( 8cc02b...5173bc )
by Christian
02:41
created

ExpressionLanguage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 2
crap 1
1
<?php
2
3
namespace uuf6429\ExpressionLanguage;
4
5
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as SymfonyExpressionLanguage;
6
7
class ExpressionLanguage extends SymfonyExpressionLanguage
8
{
9
    /** @var Parser */
10
    protected $parser;
11
12
    /**
13
     * {@inheritdoc}
14
     */
15 1
    public function __construct($cache = null, array $providers = array())
16
    {
17 1
        $this->parser = new Parser(array());
18
19 1
        parent::__construct($cache, $providers);
20
21 1
        $reflection = new \ReflectionClass(SymfonyExpressionLanguage::class);
22
23 1
        $prop = $reflection->getProperty('lexer');
24 1
        $prop->setAccessible(true);
25 1
        $prop->setValue($this, new Lexer());
26 1
        $prop->setAccessible(false);
27
28 1
        $prop = $reflection->getProperty('parser');
29 1
        $prop->setAccessible(true);
30 1
        $prop->setValue($this, $this->parser);
31 1
        $prop->setAccessible(false);
32 1
    }
33
34
    /**
35
     * Hack to keep functions in parser up to date.
36
     *
37
     * {@inheritdoc}
38
     */
39 1
    public function register($name, callable $compiler, callable $evaluator)
40
    {
41 1
        parent::register($name, $compiler, $evaluator);
42 1
        $this->parser->setFunctions($this->functions);
43 1
    }
44
}
45