1 | <?php |
||
15 | trait ValuePart { |
||
16 | |||
17 | /** @var mixed */ |
||
18 | private $value; |
||
19 | |||
20 | /** @var bool */ |
||
21 | private $hasValue = false; |
||
22 | |||
23 | /** @var string */ |
||
24 | private $expression; |
||
25 | |||
26 | /** @var bool */ |
||
27 | private $hasExpression = false; |
||
28 | |||
29 | /** |
||
30 | * @deprecated use `setValue()` instead |
||
31 | * @param mixed $value |
||
32 | * @return $this |
||
33 | */ |
||
34 | public function setDefaultValue($value) { |
||
37 | |||
38 | /** |
||
39 | * @deprecated use `unsetValue()` instead |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function unsetDefaultValue() { |
||
45 | |||
46 | /** |
||
47 | * @deprecated use `getValue()` instead |
||
48 | * @return mixed |
||
49 | */ |
||
50 | public function getDefaultValue() { |
||
53 | |||
54 | /** |
||
55 | * @deprecated use `hasValue()` instead |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function hasDefaultValue(): bool { |
||
61 | |||
62 | /** |
||
63 | * Returns whether the given value is a primitive |
||
64 | * |
||
65 | * @param mixed $value |
||
66 | * @return bool |
||
67 | */ |
||
68 | 24 | private function isPrimitive($value): bool { |
|
76 | |||
77 | /** |
||
78 | * Sets the value |
||
79 | * |
||
80 | * @param string|int|float|bool|null|PhpConstant $value |
||
81 | * @throws \InvalidArgumentException if the value is not an accepted primitve |
||
82 | * @return $this |
||
83 | */ |
||
84 | 24 | public function setValue($value) { |
|
93 | |||
94 | /** |
||
95 | * Unsets the value |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | 1 | public function unsetValue() { |
|
105 | |||
106 | /** |
||
107 | * Returns the value |
||
108 | * |
||
109 | * @return string|int|float|bool|null|PhpConstant |
||
110 | */ |
||
111 | 16 | public function getValue() { |
|
114 | |||
115 | /** |
||
116 | * Checks whether a value or expression is set |
||
117 | * |
||
118 | * @return bool |
||
119 | */ |
||
120 | 22 | public function hasValue(): bool { |
|
123 | |||
124 | /** |
||
125 | * Returns whether an expression is set |
||
126 | * |
||
127 | * @return bool |
||
128 | */ |
||
129 | 9 | public function isExpression(): bool { |
|
132 | |||
133 | /** |
||
134 | * Sets an expression |
||
135 | * |
||
136 | * @param string $expr |
||
137 | * @return $this |
||
138 | */ |
||
139 | 10 | public function setExpression(string $expr) { |
|
145 | |||
146 | /** |
||
147 | * Returns the expression |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | 8 | public function getExpression(): ?string { |
|
154 | |||
155 | /** |
||
156 | * Unsets the expression |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | 1 | public function unsetExpression() { |
|
166 | } |
||
167 |