EvaluateNode::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Patron package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Patron;
13
14
/**
15
 * An evaluation node.
16
 *
17
 * The node is evaluated with the engine's `evaluate()` method.
18
 */
19
class EvaluateNode extends ExpressionNode
20
{
21
	/**
22
	 * @var Engine
23
	 */
24
	private $engine;
25
26
	/**
27
	 * @var array
28
	 */
29
	private $engine_context;
30
31
	/**
32
	 * @inheritdoc
33
	 */
34
	public function __invoke(Engine $engine, $context)
35
	{
36
		$this->engine = $engine;
37
		$this->engine_context = $context;
38
39
		return parent::__invoke($engine, $context);
40
	}
41
42
	/**
43
	 * @inheritdoc
44
	 */
45
	protected function render($expression)
46
	{
47
		return $this->engine->evaluate($expression, false, $this->engine_context);
48
	}
49
}
50