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