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

BaseTrait   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

13 Methods

Rating   Name   Duplication   Size   Complexity  
setPropertyCtrl() 0 1 ?
addToPropertyCtrl() 0 1 ?
addToProperty() 0 1 ?
A addVariation() 0 3 1
A addState() 0 3 1
A setVariation() 0 4 1
A setState() 0 4 1
A setSize() 0 3 1
A setDisabled() 0 3 1
A setColor() 0 3 1
A setFluid() 0 3 1
A setInverted() 0 3 1
A setCircular() 0 3 1
1
<?php
2
3
namespace Ajax\semantic\html\base\traits;
4
5
use Ajax\semantic\html\base\constants\Size;
6
use Ajax\semantic\html\base\constants\Color;
7
trait BaseTrait {
8
	protected $_variations=[];
9
	protected $_states=[];
10
	protected $_baseClass;
11
12
	protected abstract function setPropertyCtrl($name, $value, $typeCtrl);
13
	protected abstract function addToPropertyCtrl($name, $value, $typeCtrl);
14
	public abstract function addToProperty($name, $value, $separator=" ");
15
16
	public function addVariation($variation){
17
		return $this->addToPropertyCtrl("class", $variation, $this->_variations);
18
	}
19
20
	public function addState($state){
21
		return $this->addToPropertyCtrl("class", $state, $this->_states);
22
	}
23
24
	public function setVariation($variation){
25
		$this->setPropertyCtrl("class", $variation, $this->_variations);
26
		return $this->addToProperty("class", $this->_baseClass);
27
	}
28
29
	public function setState($state){
30
		$this->setPropertyCtrl("class", $state, $this->_states);
31
		return $this->addToProperty("class", $this->_baseClass);
32
	}
33
34
	/**
35
	 * {@inheritDoc}
36
	 * @see \Ajax\common\html\HtmlSingleElement::setSize()
37
	 */
38
	public function setSize($size){
39
		return $this->addToPropertyCtrl("class", $size, Size::getConstants());
40
	}
41
42
	/**
43
	 * show it is currently unable to be interacted with
44
	 * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement
45
	 */
46
	public function setDisabled(){
47
		return $this->addToProperty("class", "disabled");
48
	}
49
50
	/**
51
	 * @param string $color
52
	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
53
	 */
54
	public function setColor($color){
55
		return $this->addToPropertyCtrl("class", $color,Color::getConstants());
56
	}
57
58
	/**
59
	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
60
	 */
61
	public function setFluid(){
62
		return $this->addToProperty("class", "fluid");
63
	}
64
65
	/**
66
	 * can be formatted to appear on dark backgrounds
67
	 */
68
	public function setInverted(){
69
		return $this->addToProperty("class", "inverted");
70
	}
71
72
	public function setCircular(){
73
		return $this->addToProperty("class", "circular");
74
	}
75
}