Conditions | 12 |
Paths | 20 |
Total Lines | 31 |
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 |
||
18 | public function inputAssignment($id = null) |
||
|
|||
19 | { |
||
20 | $hide_form = (request('hide_form')) ? unserialize(request('hide_form')) : []; |
||
21 | |||
22 | foreach ($this->form as $form) { |
||
23 | $name = $form['name']; |
||
24 | $type = $form['type'] ?: 'text'; |
||
25 | $inputdata = request($name); |
||
26 | |||
27 | if (! $name || in_array($name, $hide_form) || $form['exception']) { |
||
28 | continue; |
||
29 | } |
||
30 | |||
31 | $hookPath = CbComponentsPath($type).DIRECTORY_SEPARATOR.'hookInputAssignment.php'; |
||
32 | if (file_exists($hookPath)) { |
||
33 | require_once($hookPath); |
||
34 | } |
||
35 | unset($hookPath); |
||
36 | |||
37 | if (Request::hasFile($name)) { |
||
38 | continue; |
||
39 | } |
||
40 | |||
41 | if ($inputdata == '' && DbInspector::isNullableColumn($this->table, $name)) { |
||
42 | continue; |
||
43 | } |
||
44 | |||
45 | $this->arr[$name] = ''; |
||
46 | |||
47 | if ($inputdata != '') { |
||
48 | $this->arr[$name] = $inputdata; |
||
49 | } |
||
112 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.