Conditions | 12 |
Paths | 20 |
Total Lines | 31 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
13 | public function inputAssignment($id = null) |
||
|
|||
14 | { |
||
15 | $hide_form = (request('hide_form')) ? unserialize(request('hide_form')) : []; |
||
16 | |||
17 | foreach ($this->form as $form) { |
||
18 | $name = $form['name']; |
||
19 | $type = $form['type'] ?: 'text'; |
||
20 | $inputdata = request($name); |
||
21 | |||
22 | if (! $name || in_array($name, $hide_form) || $form['exception']) { |
||
23 | continue; |
||
24 | } |
||
25 | |||
26 | $hookPath = \CB::componentsPath($type).DIRECTORY_SEPARATOR.'hookInputAssignment.php'; |
||
27 | if (file_exists($hookPath)) { |
||
28 | require_once($hookPath); |
||
29 | } |
||
30 | unset($hookPath); |
||
31 | |||
32 | if (Request::hasFile($name)) { |
||
33 | continue; |
||
34 | } |
||
35 | |||
36 | if ($inputdata == '' && CB::isColumnNULL($this->table, $name)) { |
||
37 | continue; |
||
38 | } |
||
39 | |||
40 | $this->arr[$name] = ''; |
||
41 | |||
42 | if ($inputdata != '') { |
||
43 | $this->arr[$name] = $inputdata; |
||
44 | } |
||
108 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.