Conditions | 9 |
Paths | 69 |
Total Lines | 51 |
Code 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 |
||
74 | public function getViewFields(string $view): array |
||
75 | { |
||
76 | // From table.inc.php |
||
77 | $fields = $this->driver->fields($view); |
||
78 | if (empty($fields)) { |
||
79 | throw new Exception($this->driver->error()); |
||
80 | } |
||
81 | |||
82 | $tabs = [ |
||
83 | 'fields' => $this->utils->trans->lang('Columns'), |
||
84 | // 'triggers' => $this->utils->trans->lang('Triggers'), |
||
85 | ]; |
||
86 | if ($this->driver->support('view_trigger')) { |
||
87 | $tabs['triggers'] = $this->utils->trans->lang('Triggers'); |
||
88 | } |
||
89 | |||
90 | $headers = [ |
||
91 | $this->utils->trans->lang('Name'), |
||
92 | $this->utils->trans->lang('Type'), |
||
93 | $this->utils->trans->lang('Collation'), |
||
94 | ]; |
||
95 | $hasComment = $this->driver->support('comment'); |
||
96 | if ($hasComment) { |
||
97 | $headers[] = $this->utils->trans->lang('Comment'); |
||
98 | } |
||
99 | |||
100 | $details = []; |
||
101 | foreach ($fields as $field) { |
||
102 | $type = $this->utils->str->html($field->fullType); |
||
103 | if ($field->null) { |
||
104 | $type .= ' <i>nullable</i>'; // ' <i>NULL</i>'; |
||
105 | } |
||
106 | if ($field->autoIncrement) { |
||
107 | $type .= ' <i>' . $this->utils->trans->lang('Auto Increment') . '</i>'; |
||
108 | } |
||
109 | if ($field->hasDefault) { |
||
110 | $type .= /*' ' . $this->utils->trans->lang('Default value') .*/ ' [<b>' . $this->utils->str->html($field->default) . '</b>]'; |
||
111 | } |
||
112 | $detail = [ |
||
113 | 'name' => $this->utils->str->html($field->name), |
||
114 | 'type' => $type, |
||
115 | 'collation' => $this->utils->str->html($field->collation), |
||
116 | ]; |
||
117 | if ($hasComment) { |
||
118 | $detail['comment'] = $this->utils->str->html($field->comment); |
||
119 | } |
||
120 | |||
121 | $details[] = $detail; |
||
122 | } |
||
123 | |||
124 | return compact('headers', 'details'); |
||
125 | } |
||
237 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.