Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php namespace Mascame\Artificer\Fields; |
||
6 | class Field implements FieldInterface |
||
7 | { |
||
8 | use Filterable; |
||
9 | |||
10 | /** |
||
11 | * @var |
||
12 | */ |
||
13 | public $name; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | public $type; |
||
19 | |||
20 | /** |
||
21 | * @var mixed |
||
22 | */ |
||
23 | public $title; |
||
24 | |||
25 | /** |
||
26 | * @var null |
||
27 | */ |
||
28 | public $value; |
||
29 | |||
30 | public static $widgets = array(); |
||
31 | /** |
||
32 | * @var FieldOptions |
||
33 | */ |
||
34 | public $options; |
||
35 | |||
36 | /** |
||
37 | * @var FieldRelation |
||
38 | */ |
||
39 | public $relation; |
||
40 | |||
41 | /** |
||
42 | * @var mixed |
||
43 | */ |
||
44 | public $wiki; |
||
45 | |||
46 | /** |
||
47 | * @var FieldAttributes |
||
48 | */ |
||
49 | public $attributes; |
||
50 | |||
51 | /** |
||
52 | * Sometimes ajax limits output, setting this to true will return all |
||
53 | * |
||
54 | * @var bool |
||
55 | */ |
||
56 | public $showFullField = false; |
||
57 | |||
58 | |||
59 | /** |
||
60 | * @param $name |
||
61 | * @param null $value |
||
62 | * @param $modelName |
||
63 | * @param $relation |
||
64 | */ |
||
65 | public function __construct($name, $value = null, $relation) |
||
85 | |||
86 | /** |
||
87 | * @param string $type_class |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getType($type_class) |
||
96 | |||
97 | |||
98 | /** |
||
99 | * @param $widget |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function addWidget(AbstractWidget $widget) |
||
112 | |||
113 | |||
114 | /** |
||
115 | * Used to load custom assets, widgets, ... |
||
116 | * |
||
117 | */ |
||
118 | public function boot() |
||
134 | |||
135 | |||
136 | /** |
||
137 | * @return null |
||
138 | */ |
||
139 | public function show() |
||
143 | |||
144 | /** |
||
145 | * @param null $value |
||
146 | * @return null |
||
147 | */ |
||
148 | // public function display($value = null) |
||
149 | // { |
||
150 | // $this->value = $this->getValue($value); |
||
151 | // |
||
152 | // return $this->show(); |
||
153 | // } |
||
154 | |||
155 | |||
156 | /** |
||
157 | * @param null $value |
||
158 | * @return null |
||
159 | */ |
||
160 | public function getValue($value = null) |
||
174 | |||
175 | |||
176 | /** |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function input() |
||
183 | |||
184 | |||
185 | /** |
||
186 | * @param $input |
||
187 | * @return mixed |
||
188 | */ |
||
189 | public function userInput($input) |
||
197 | |||
198 | |||
199 | /** |
||
200 | * @return bool|mixed|null|string |
||
201 | */ |
||
202 | public function output() |
||
216 | |||
217 | |||
218 | /** |
||
219 | * @return string |
||
220 | */ |
||
221 | public function hidden() |
||
225 | |||
226 | /** |
||
227 | * @param $array |
||
228 | * @return bool |
||
229 | */ |
||
230 | protected function isAll($array) |
||
234 | |||
235 | /** |
||
236 | * @param string $list |
||
237 | * @return bool |
||
238 | */ |
||
239 | public function isListed($list = 'show') |
||
253 | |||
254 | |||
255 | /** |
||
256 | * @return bool |
||
257 | */ |
||
258 | public function isHiddenList() |
||
262 | |||
263 | |||
264 | /** |
||
265 | * @param $value |
||
266 | * @param $array |
||
267 | * @return bool |
||
268 | */ |
||
269 | public function isInArray($value, $array) |
||
273 | |||
274 | |||
275 | /** |
||
276 | * @return string |
||
277 | */ |
||
278 | public function guarded() |
||
282 | |||
283 | /** |
||
284 | * @return bool |
||
285 | */ |
||
286 | View Code Duplication | public function isGuarded() |
|
294 | |||
295 | |||
296 | /** |
||
297 | * @return bool |
||
298 | */ |
||
299 | View Code Duplication | public function isHidden() |
|
307 | |||
308 | /** |
||
309 | * @return bool |
||
310 | */ |
||
311 | public function isRelation() |
||
315 | |||
316 | public static function get($name) |
||
320 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.