Passed
Branch develop (3f8649)
by Michael
03:13
created

View   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 25
wmc 2
lcom 0
cbo 0
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 15 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