HtmlListItem   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 35
c 3
b 1
f 0
dl 0
loc 56
rs 10
wmc 13

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getItem() 0 2 1
A getList() 0 2 1
B initContent() 0 30 8
A addList() 0 7 2
1
<?php
2
namespace Ajax\semantic\html\content;
3
4
use Ajax\service\JArray;
5
use Ajax\semantic\html\elements\HtmlList;
6
7
class HtmlListItem extends HtmlAbsractItem {
8
9
	protected $image;
10
11
	public function __construct($identifier, $content = NULL) {
12
		parent::__construct($identifier, "item", $content);
13
	}
14
15
	protected function initContent($content) {
16
		if (\is_array($content)) {
17
			if (JArray::isAssociative($content) === false) {
18
				$icon = $content[0] ?? null;
19
				$title = $content[1] ?? null;
20
				$desc = $content[2] ?? null;
21
			} else {
22
				$icon = $content["icon"] ?? null;
23
				$image = $content["image"] ?? null;
24
				$title = $content["title"] ?? null;
25
				$header = $content["header"] ?? null;
26
				$desc = $content["description"] ?? null;
27
				$items = $content["items"] ?? null;
28
			}
29
			if (isset($icon)) {
30
				$this->setIcon($icon);
31
			}
32
			if (isset($image)) {
33
				$this->setImage($image);
34
			}
35
			if (isset($title)) {
36
				$this->setTitle($title, $desc);
37
			} elseif (isset($header)) {
38
				$this->setTitle($header, $desc, "header");
39
			}
40
			if (isset($items)) {
41
				$this->addList($items);
42
			}
43
		} else {
44
			$this->setContent($content);
45
		}
46
	}
47
48
	public function addList($items = array(), $ordered = false) {
49
		$list = new HtmlList("", $items);
50
		if ($ordered)
51
			$list->setOrdered();
52
		$list->setClass("list");
53
		$this->content["list"] = $list;
54
		return $list;
55
	}
56
57
	public function getList() {
58
		return $this->content["list"];
59
	}
60
61
	public function getItem($index) {
62
		return $this->getList()->getItem($index);
63
	}
64
}
65