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

HtmlCardGroups   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createItem() 0 11 2
A getCard() 0 3 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
}