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

Php   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
ccs 14
cts 14
cp 1
rs 10
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A render() 0 14 1
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