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

Widgets::items()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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