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

ExpressionLanguage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 38
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 1
A register() 0 5 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