Passed
Push — master ( 7dac2b...30127e )
by Atanas
01:55
created

Php::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 2
ccs 11
cts 11
cp 1
crap 1
rs 9.4285
1
<?php
2
3
namespace WPEmerge\View;
4
5
/**
6
 * Render view files with php
7
 */
8
class Php implements EngineInterface {
9
	/**
10
	 * Global context
11
	 *
12
	 * @var array
13
	 */
14
	protected $global_context = [];
15
16
	/**
17
	 * Constructor
18
	 *
19
	 * @param array $global_context
20
	 */
21 2
	public function __construct( $global_context ) {
22 2
		$this->global_context = $global_context;
23 2
	}
24
25
	/**
26
	 * {@inheritDoc}
27
	 */
28 4
	public function render( $file, $context ) {
29 4
		$__view = $file;
30 4
		$__context = array_merge(
31 4
			['global' => $this->global_context],
32 4
			$context
33
		);
34 4
		$renderer = function() use ( $__view, $__context ) {
35 4
			ob_start();
36 4
			extract( $__context );
37 4
			include( $__view );
38 4
			return ob_get_clean();
39 4
		};
40
		return $renderer();
41
	}
42
}
43