Conditions | 8 |
Paths | 4 |
Total Lines | 58 |
Code Lines | 44 |
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 |
||
119 | public function run(): Pass { |
||
120 | $pass = parent::run(); |
||
121 | $views = views_get_all_views(TRUE); |
||
122 | foreach ($views as $view) { |
||
123 | $pass->record($this->checkViewPhp($view)); |
||
124 | } |
||
125 | $pass->life->end(); |
||
126 | |||
127 | if ($pass->status) { |
||
128 | $result = format_plural(count($views), '1 view checked, none containing PHP', |
||
129 | '@count views checked, none containing PHP', []); |
||
130 | } |
||
131 | else { |
||
132 | $result = format_plural(count($views), '1 view checked and containing PHP', |
||
133 | '@count views checked, @php containing PHP', [ |
||
134 | '@php' => count($pass->result), |
||
135 | ]); |
||
136 | $header = [ |
||
137 | t('View'), |
||
138 | t('Display'), |
||
139 | t('Area'), |
||
140 | t('Field'), |
||
141 | t('Content'), |
||
142 | ]; |
||
143 | $data = []; |
||
144 | foreach ($pass->result as $view_name => $displays) { |
||
145 | $row = []; |
||
146 | $link_title = empty($views[$view_name]->human_name) |
||
147 | ? $view_name |
||
148 | : $views[$view_name]->human_name; |
||
149 | $view_link = l($link_title, "admin/structure/views/view/$view_name/edit"); |
||
150 | $row['view'] = ['data' => $view_link]; |
||
151 | foreach ($displays as $display_id => $areas) { |
||
152 | $row['display'] = l($display_id, "admin/structure/views/view/$view_name/edit/$display_id"); |
||
153 | foreach ($areas as $area_name => $fields) { |
||
154 | $row['area'] = l($area_name, "admin/structure/views/nojs/rearrange/$view_name/$display_id/$area_name"); |
||
155 | foreach ($fields as $field => $content) { |
||
156 | $row['field'] = l($field, |
||
157 | 'admin/structure/views/nojs/config-item/'. $view_name .'/'. $display_id .'/'. $area_name .'/'. $field, |
||
158 | ['query' => ['destination' => 'admin/reports/qa/results']] |
||
159 | ); |
||
160 | $row['content'] = [ |
||
161 | 'data' => '<pre>'. check_plain($content) .'</pre>', |
||
162 | 'class' => 'pre', |
||
163 | ]; |
||
164 | $data[$view_name .'/'. $display_id .'/'. $area_name .'/'. $field] = $row; |
||
165 | } |
||
166 | } |
||
167 | } |
||
168 | } |
||
169 | ksort($data); |
||
170 | $result .= theme('table', [ |
||
171 | 'header' => $header, |
||
172 | 'rows' => $data, |
||
173 | ]); |
||
174 | } |
||
175 | $pass->result = $result; |
||
176 | return $pass; |
||
177 | } |
||
180 |