Completed
Push — master ( e04e71...98392d )
by Jean-Christophe
03:50
created

HtmlCardGroups::getCard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\views;
4
5
use Ajax\semantic\html\base\HtmlSemCollection;
6
use Ajax\service\JArray;
7
8
class HtmlCardGroups extends HtmlSemCollection {
9
10
	public function __construct($identifier, $cards=array()) {
11
		parent::__construct($identifier, "div", "ui cards");
12
		$this->addItems($cards);
13
	}
14
15
	protected function createItem($value) {
16
		$result=new HtmlCard("card-" . $this->count());
17
		if (\is_array($value)) {
18
			$header=JArray::getValue($value, "header", 0);
19
			$metas=JArray::getValue($value, "metas", 1);
20
			$description=JArray::getValue($value, "description", 2);
21
			$result->addCardHeaderContent($header, $metas, $description);
22
		} else
23
			$result->addCardContent($value);
24
		return $result;
25
	}
26
27
	public function getCard($index) {
28
		return $this->getItem($index);
29
	}
30
}