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

HtmlCardHeaderContent::__construct()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 5
eloc 11
nc 8
nop 4
1
<?php
2
3
namespace Ajax\semantic\html\content\card;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\JsUtils;
7
use Phalcon\Mvc\View;
8
use Ajax\service\JArray;
9
10
class HtmlCardHeaderContent extends HtmlCardContent {
11
12
	public function __construct($identifier, $header=NULL, $metas=array(), $description=NULL) {
13
		parent::__construct($identifier, array ());
14
		if (isset($header)) {
15
			$this->setHeader($header);
16
		}
17
		if (\is_array($metas)) {
18
			foreach ( $metas as $meta ) {
19
				$this->addMeta($meta);
20
			}
21
		} else
22
			$this->addMeta($metas);
23
		if (isset($description)) {
24
			$this->setDescription($description);
25
		}
26
	}
27
28
	public function setDescription($value) {
29
		$this->content["description"]=new HtmlSemDoubleElement("description-" . $this->identifier, "div", "description", $value);
30
	}
31
32
	public function setHeader($value) {
33
		$this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value);
34
	}
35
36
	/**
37
	 *
38
	 * {@inheritDoc}
39
	 *
40
	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile()
41
	 */
42
	public function compile(JsUtils $js=NULL, View $view=NULL) {
43
		$this->content=JArray::sortAssociative($this->content, [ "header","meta","description" ]);
44
		return parent::compile($js, $view);
45
	}
46
}