AbstractWidget   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getView() 0 8 2
A render() 0 4 1
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL, Commercial` license[s].
5
 *
6
 * @package maslosoft/zamm
7
 * @license AGPL, Commercial
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/zamm/
11
 */
12
13
namespace Maslosoft\Zamm\Widgets;
14
15
use Maslosoft\MiniView\MiniView;
16
17
/**
18
 * Base class for widgets to simplify development. It
19
 * provides pre-configured view.
20
 *
21
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
22
 */
23
abstract class AbstractWidget
24
{
25
26
	/**
27
	 * Mini view instance
28
	 * @var MiniView
29
	 */
30
	private $view = null;
31
32
	/**
33
	 *
34
	 * @return MiniView
35
	 */
36
	public function getView()
37
	{
38
		if (empty($this->view))
39
		{
40
			$this->view = new MiniView($this);
41
		}
42
		return $this->view;
43
	}
44
45
	/**
46
	 * 
47
	 * @param string $view
48
	 * @param mixed $data
49
	 * @return string
50
	 */
51
	public function render($view, $data = [])
52
	{
53
		return $this->getView()->render($view, $data, true);
54
	}
55
56
}
57