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
|
|
|
public function addVariation($variation){ |
13
|
|
|
return $this->addToPropertyCtrl("class", $variation, $this->_variations); |
|
|
|
|
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function addState($state){ |
17
|
|
|
return $this->addToPropertyCtrl("class", $state, $this->_states); |
|
|
|
|
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function setVariation($variation){ |
21
|
|
|
$this->setPropertyCtrl("class", $variation, $this->_variations); |
|
|
|
|
22
|
|
|
return $this->addToProperty("class", $this->_baseClass); |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function setState($state){ |
26
|
|
|
$this->setPropertyCtrl("class", $state, $this->_states); |
|
|
|
|
27
|
|
|
return $this->addToProperty("class", $this->_baseClass); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritDoc} |
32
|
|
|
* @see \Ajax\common\html\HtmlSingleElement::setSize() |
33
|
|
|
*/ |
34
|
|
|
public function setSize($size){ |
35
|
|
|
return $this->addToPropertyCtrl("class", $size, Size::getConstants()); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* show it is currently unable to be interacted with |
40
|
|
|
* @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
41
|
|
|
*/ |
42
|
|
|
public function setDisabled(){ |
43
|
|
|
return $this->addToProperty("class", "disabled"); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param string $color |
48
|
|
|
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
49
|
|
|
*/ |
50
|
|
|
public function setColor($color){ |
51
|
|
|
return $this->addToPropertyCtrl("class", $color,Color::getConstants()); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setFluid(){ |
55
|
|
|
$this->addToProperty("class", "fluid"); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* can be formatted to appear on dark backgrounds |
60
|
|
|
*/ |
61
|
|
|
public function setInverted(){ |
62
|
|
|
$this->addToProperty("class", "inverted"); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
} |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.