Completed
Push — master ( 2e4917...2e950a )
by Klaus
19:05 queued 19:05
created

Interpreter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Component\RuleEngine;
6
7
use Linio\Common\Type\Dictionary;
8
use Linio\Component\RuleEngine\Ast\CompileNode;
9
use Linio\Component\RuleEngine\Parser\ParserInterface;
10
11
class Interpreter
12
{
13
    protected ?ParserInterface $parser;
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 '?', expecting T_FUNCTION or T_CONST
Loading history...
14
15
    public function parse(string $inputString): CompileNode
16
    {
17
        return $this->parser->parse($inputString);
18
    }
19
20
    public function evaluate(string $inputString, Dictionary $context)
21
    {
22
        $node = $this->parser->parse($inputString);
23
        $node->setContext($context);
24
25
        return $node->evaluate();
26
    }
27
28
    public function setParser(ParserInterface $parser): void
29
    {
30
        $this->parser = $parser;
31
    }
32
}
33