1 | <?php |
||
17 | trait HasRevaluableAttributes |
||
18 | { |
||
19 | /** |
||
20 | * Revaluated attributes append to array. |
||
21 | * |
||
22 | * @var bool |
||
23 | */ |
||
24 | //protected $appendRevaluatedAttributesToArray = true; |
||
|
|||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | //protected $replaceRawAttributesToArray = false; |
||
30 | |||
31 | /** |
||
32 | * Prefix of revaluated attribute getter. |
||
33 | * |
||
34 | * <pre> |
||
35 | * $model->revaluated_price; |
||
36 | * </pre> |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | //protected $revaluatedAttributePrefix = 'revaluated'; |
||
41 | |||
42 | /** |
||
43 | * Return valuator instance of attribute. |
||
44 | * |
||
45 | * @param string $attribute |
||
46 | * |
||
47 | * @return \Overtrue\LaravelRevaluation\Revaluable |
||
48 | */ |
||
49 | public function getRevaluatedAttribute($attribute) |
||
59 | |||
60 | /** |
||
61 | * Return revaluable attributes. |
||
62 | * |
||
63 | * @example |
||
64 | * |
||
65 | * <pre> |
||
66 | * // 1. Using default valuator: |
||
67 | * protected $revaluable = [ |
||
68 | * 'foo', 'bar', 'baz' |
||
69 | * ]; |
||
70 | * |
||
71 | * // 2. Use the specified valuator: |
||
72 | * protected $revaluable = [ |
||
73 | * 'foo' => '\Foo\Support\Valuator\Foo', |
||
74 | * 'bar' => '\Foo\Support\Valuator\Bar', |
||
75 | * 'baz', |
||
76 | * ]; |
||
77 | * </pre> |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function getRevaluableAttributes() |
||
99 | |||
100 | /** |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getRevaluableAttributePrefix() |
||
107 | |||
108 | /** |
||
109 | * @example |
||
110 | * <pre> |
||
111 | * $object->revaluated_price; |
||
112 | * $object->raw_price; |
||
113 | * </pre> |
||
114 | * |
||
115 | * @param string $attribute |
||
116 | * |
||
117 | * @return mixed |
||
118 | * |
||
119 | * @throws \Exception |
||
120 | */ |
||
121 | public function getAttribute($attribute) |
||
142 | |||
143 | /** |
||
144 | * Set attribute. |
||
145 | * |
||
146 | * @param string $attribute |
||
147 | * @param mixed $value |
||
148 | * |
||
149 | * @return $this |
||
150 | */ |
||
151 | public function setAttribute($attribute, $value) |
||
159 | |||
160 | /** |
||
161 | * Run the increment or decrement method on the model. |
||
162 | * |
||
163 | * @param string $column |
||
164 | * @param int $amount |
||
165 | * @param array $extra |
||
166 | * @param string $method |
||
167 | * |
||
168 | * @return int |
||
169 | */ |
||
170 | protected function incrementOrDecrement($column, $amount, $extra, $method) |
||
189 | |||
190 | /** |
||
191 | * Override HasAttributes::attributesToArray. |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | public function attributesToArray() |
||
210 | |||
211 | /** |
||
212 | * @param string $attribute |
||
213 | * |
||
214 | * @return string |
||
215 | */ |
||
216 | public function getRevaluablePrefixedAttributeName($attribute) |
||
220 | |||
221 | /** |
||
222 | * Fetch attribute. |
||
223 | * |
||
224 | * @example |
||
225 | * <pre> |
||
226 | * $object->getRevaluatedPriceAttribute(); |
||
227 | * $object->getRevaluatedXXXAttribute(); |
||
228 | * </pre> |
||
229 | * |
||
230 | * @param string $method |
||
231 | * |
||
232 | * @return mixed |
||
233 | */ |
||
234 | public function __call($method, $args) |
||
243 | |||
244 | /** |
||
245 | * @return bool |
||
246 | */ |
||
247 | protected function shouldAppendRevaluatedAttributesToArray() |
||
251 | |||
252 | /** |
||
253 | * @return bool |
||
254 | */ |
||
255 | protected function shouldReplaceRawAttributesToArray() |
||
259 | |||
260 | /** |
||
261 | * Return revaluated value of attribute. |
||
262 | * |
||
263 | * @param string $attribute |
||
264 | * |
||
265 | * @return mixed |
||
266 | */ |
||
267 | protected function getStorableValue($attribute) |
||
277 | |||
278 | /** |
||
279 | * Get attribute valuator. |
||
280 | * |
||
281 | * @param string $attribute |
||
282 | * |
||
283 | * @return string |
||
284 | */ |
||
285 | protected function getAttributeValuator($attribute) |
||
289 | } |
||
290 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.