Completed
Push — master ( 2461e8...b569b1 )
by Jean-Christophe
04:01
created

HtmlReveal   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
B setElement() 0 13 5
A setVisibleContent() 0 3 1
A setHiddenContent() 0 3 1
A getVisibleContent() 0 3 1
A getHiddenContent() 0 3 1
A setType() 0 7 2
A setFade() 0 3 1
A setMove() 0 3 1
A setRotate() 0 3 1
A setCircular() 0 3 1
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\base\constants\RevealType;
7
use Ajax\semantic\html\base\constants\Direction;
8
use Ajax\common\html\html5\HtmlImg;
9
use Ajax\common\html\HtmlSingleElement;
10
11
class HtmlReveal extends HtmlSemDoubleElement {
12
13
	public function __construct($identifier, $visibleContent,$hiddenContent,$type=RevealType::FADE,$attributeType=NULL) {
14
		parent::__construct($identifier, "div", "ui reveal");
15
		$this->setElement(0, $visibleContent);
16
		$this->setElement(1, $hiddenContent);
17
		$this->setType($type,$attributeType);
18
	}
19
20
	private function setElement($index,$content){
21
		if(!$content instanceof HtmlSingleElement){
22
			$content=new HtmlLabel("",$content);
23
		}
24
		if($content instanceof HtmlSemDoubleElement){
25
			$content=new HtmlSemDoubleElement($this->identifier."-".$index,"div","",$content);
26
		}elseif ($content instanceof HtmlImg){
27
			$this->addToPropertyCtrl("class", "image", array("image"));
28
		}
29
		$content->addToProperty("class",(($index===0)?"visible":"hidden")." content");
30
		$this->content[$index]=$content;
31
		return $this;
32
	}
33
34
	public function setVisibleContent($visibleContent){
35
		return $this->setElement(0, $visibleContent);
36
	}
37
38
	public function setHiddenContent($hiddenContent){
39
		return $this->setElement(1, $hiddenContent);
40
	}
41
42
	public function getVisibleContent(){
43
		return $this->content[0];
44
	}
45
46
	public function getHiddenContent(){
47
		return $this->content[1];
48
	}
49
50
	public function setType($type,$attribute=NULL){
51
		$this->addToPropertyCtrl("class", $type, RevealType::getConstants());
52
		if(isset($attribute)){
53
			$this->addToPropertyCtrl("class", $attribute, Direction::getConstants());
54
		}
55
		return $this;
56
	}
57
58
	public function setFade($attribute=NULL){
59
		return $this->setType(RevealType::FADE,$attribute);
60
	}
61
62
	public function setMove($attribute=NULL){
63
		return $this->setType(RevealType::MOVE,$attribute);
64
	}
65
66
	public function setRotate($attribute=NULL){
67
		return $this->setType(RevealType::ROTATE,$attribute);
68
	}
69
70
	public function setCircular(){
71
		return $this->addToProperty("class", "circular");
72
	}
73
74
}