Completed
Push — master ( aa5a0d...109f75 )
by Peter
05:58
created

PhpRenderer::render()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 24
Code Lines 13

Duplication

Lines 24
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 24
loc 24
rs 8.9713
cc 3
eloc 13
nc 4
nop 3
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace Maslosoft\MiniView\Renderers;
10
11
use Maslosoft\MiniView\Interfaces\OwnerAwareInterface;
12
use Maslosoft\MiniView\Interfaces\OwnerForwarderInterface;
13
use Maslosoft\MiniView\Interfaces\ViewRendererInterface;
14
15
/**
16
 * PhpRenderer
17
 *
18
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
19
 */
20
class PhpRenderer implements ViewRendererInterface, OwnerAwareInterface, OwnerForwarderInterface
21
{
22
23
	use \Maslosoft\MiniView\Traits\OwnerAwareTrait,
24
	  \Maslosoft\MiniView\Traits\OwnerForwarderTrait;
25
26
	/**
27
	 * Render php file
28
	 * @param string $_viewFile_
29
	 * @param mixed $_data_
30
	 * @param bool $_return_
31
	 * @return string
32
	 */
33 View Code Duplication
	public function render($_viewFile_, $_data_, $_return_ = false)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
	{
35
		$_viewFile_ = sprintf('%s.php', $_viewFile_);
36
		// we use special variable names here to avoid conflict when extracting data
37
		if (is_array($_data_))
38
		{
39
			extract($_data_, EXTR_PREFIX_SAME, 'data');
40
		}
41
		else
42
		{
43
			$data = $_data_;
44
		}
45
		if ($_return_)
46
		{
47
			ob_start();
48
			ob_implicit_flush(false);
49
			require($_viewFile_);
50
			return ob_get_clean();
51
		}
52
		else
53
		{
54
			require($_viewFile_);
55
		}
56
	}
57
58
}
59