1 | <?php |
||
13 | trait ValuePart { |
||
14 | |||
15 | /** @var mixed */ |
||
16 | private $value; |
||
17 | |||
18 | /** @var bool */ |
||
19 | private $hasValue = false; |
||
20 | |||
21 | /** @var string */ |
||
22 | private $expression; |
||
23 | |||
24 | /** @var bool */ |
||
25 | private $hasExpression = false; |
||
26 | |||
27 | /** |
||
28 | * @deprecated use `setValue()` instead |
||
29 | * @param mixed $value |
||
30 | * @return $this |
||
31 | */ |
||
32 | public function setDefaultValue($value) { |
||
33 | return $this->setValue($value); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @deprecated use `unsetValue()` instead |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function unsetDefaultValue() { |
||
41 | return $this->unsetValue(); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @deprecated use `getValue()` instead |
||
46 | * @return mixed |
||
47 | */ |
||
48 | public function getDefaultValue() { |
||
49 | return $this->getValue(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @deprecated use `hasValue()` instead |
||
54 | * @return bool |
||
55 | */ |
||
56 | public function hasDefaultValue() { |
||
57 | return $this->hasValue(); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Returns whether the given value is a primitive |
||
62 | * |
||
63 | * @param mixed $value |
||
64 | * @return boolean |
||
65 | */ |
||
66 | 28 | private function isPrimitive($value) { |
|
74 | |||
75 | /** |
||
76 | * Sets the value |
||
77 | * |
||
78 | * @param string|integer|float|bool|null|PhpConstant $value |
||
79 | * @throws \InvalidArgumentException if the value is not an accepted primitve |
||
80 | * @return $this |
||
81 | */ |
||
82 | 28 | public function setValue($value) { |
|
91 | |||
92 | /** |
||
93 | * Unsets the value |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | 1 | public function unsetValue() { |
|
103 | |||
104 | /** |
||
105 | * Returns the value |
||
106 | * |
||
107 | * @return string|integer|float|bool|null|PhpConstant |
||
108 | */ |
||
109 | 18 | public function getValue() { |
|
112 | |||
113 | /** |
||
114 | * Checks whether a value or expression is set |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 21 | public function hasValue() { |
|
121 | |||
122 | /** |
||
123 | * Returns whether an expression is set |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | 9 | public function isExpression() { |
|
130 | |||
131 | /** |
||
132 | * Sets an expression |
||
133 | * |
||
134 | * @param string $expr |
||
135 | * @return $this |
||
136 | */ |
||
137 | 11 | public function setExpression($expr) { |
|
143 | |||
144 | /** |
||
145 | * Returns the expression |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | 8 | public function getExpression() { |
|
152 | |||
153 | /** |
||
154 | * Unsets the expression |
||
155 | * |
||
156 | * @return $this |
||
157 | */ |
||
158 | 1 | public function unsetExpression() { |
|
164 | } |
||
165 |