1 | <?php |
||
12 | trait ConditionalizableTrait |
||
13 | { |
||
14 | /** |
||
15 | * Condition needed to render the entity. |
||
16 | * |
||
17 | * @var string|boolean |
||
18 | */ |
||
19 | private $condition; |
||
20 | |||
21 | /** |
||
22 | * rendered condition. |
||
23 | * |
||
24 | * @var string|boolean |
||
25 | */ |
||
26 | private $resolvedCondition; |
||
27 | |||
28 | /** |
||
29 | * @return boolean |
||
30 | */ |
||
31 | public function resolvedCondition() |
||
45 | |||
46 | /** |
||
47 | * @return boolean|string |
||
48 | */ |
||
49 | public function condition() |
||
53 | |||
54 | /** |
||
55 | * @param boolean|string $condition A condition to evaluate. |
||
56 | * @throws InvalidArgumentException If the condition is not a string nor boolean. |
||
57 | * @return self |
||
58 | */ |
||
59 | public function setCondition($condition) |
||
71 | |||
72 | /** |
||
73 | * Resolve the conditional logic. |
||
74 | * |
||
75 | * @param mixed $condition The condition. |
||
76 | * @return boolean|null |
||
77 | */ |
||
78 | final protected function parseConditionalLogic($condition) |
||
100 | |||
101 | /** |
||
102 | * Parse the widget's conditional logic. |
||
103 | * |
||
104 | * @param callable|string $condition The callable or renderable condition. |
||
105 | * @return boolean |
||
106 | */ |
||
107 | protected function resolveConditionalLogic($condition) |
||
119 | } |
||
120 |
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.