Completed
Push — 0.2.1 ( e70612...dab97b )
by Anton
04:42
created

Widgets   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addItem() 0 4 1
A __construct() 0 12 4
A items() 0 4 1
1
<?php
2
3
namespace Utils\Template {
4
5
	use DB, Template;
6
7
	class Widgets {
8
9
		private $items = [];
10
11
		# Add item
12
13
		private function addItem(string $name, string $contents) {
14
15
			$this->items[$name] = Template::block($contents);
16
		}
17
18
		# Constructor
19
20
		public function __construct() {
21
22
			# Process selection
23
24
			$selection = ['name', 'contents']; $condition = ['display' => 1]; $order = ['name' => 'ASC'];
25
26
			if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) return;
27
28
			# Process results
29
30
			while (null !== ($widget = DB::last()->row())) $this->addItem($widget['name'], $widget['contents']);
31
		}
32
33
		# Return items
34
35
		public function items() {
36
37
			return $this->items;
38
		}
39
	}
40
}
41