Completed
Push — master ( 6b435b...aa56bd )
by Michael
04:42 queued 02:15
created

View::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 9
nc 2
nop 2
crap 2
1
<?php
2
3
/**
4
 * This file is part of the miBadger package.
5
 *
6
 * @author Michael Webbers <[email protected]>
7
 * @license http://opensource.org/licenses/Apache-2.0 Apache v2 License
8
 * @version 1.0.0
9
 */
10
11
namespace miBadger\Mvc;
12
13
/**
14
 * The view class of the MVC pattern.
15
 *
16
 * @see http://en.wikipedia.org/wiki/Model–view–controller
17
 * @since 1.0.0
18
 */
19
class View
20
{
21
	/**
22
	 * Returns the view at the given path with the given data.
23
	 *
24
	 * @param string $path
25
	 * @param string[] $data = []
26
	 * @return string a string representation of the view.
27
	 */
28 2
	public static function get($path, $data = [])
29
	{
30 2
		ob_start();
31
32 2
		extract($data);
33
34
		try {
35 2
			include $path;
36 2
		} catch (\Exception $e) {
37 1
			ob_get_clean();
38 1
			throw $e;
39
		}
40
41 1
		return ob_get_clean();
42
	}
43
}
44