Completed
Push — master ( b4ccca...781bd5 )
by Jean-Christophe
03:50
created

HtmlCardContent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addMeta() 0 9 2
A addContentIcon() 0 12 2
1
<?php
2
3
namespace Ajax\semantic\html\content\card;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\base\constants\Direction;
7
8
class HtmlCardContent extends HtmlSemDoubleElement {
9
10
	public function __construct($identifier, $content=array()) {
11
		parent::__construct($identifier, "div", "content", $content);
12
	}
13
14
	public function addMeta($value, $direction=Direction::LEFT) {
15
		if (\array_key_exists("meta", $this->content) === false) {
16
			$this->content["meta"]=array ();
17
		}
18
		$meta=new HtmlSemDoubleElement("meta-" . \sizeof($this->content["meta"]) . "" . $this->identifier, "div", "meta", $value);
19
		$this->content["meta"][]=$meta;
20
		$meta->setFloated($direction);
21
		return $meta;
22
	}
23
24
	public function addContentIcon($icon, $caption=NULL, $direction=Direction::LEFT) {
25
		if ($direction === Direction::RIGHT) {
26
			$result=new HtmlSemDoubleElement("", "span", "", $caption);
27
			$result->setFloated($direction);
28
			$result->addIcon($icon);
29
			$this->addContent($result);
30
		} else {
31
			$this->addIcon($icon);
32
			$result=$this->addContent($caption);
33
		}
34
		return $result;
35
	}
36
}