Conditions | 3 |
Paths | 3 |
Total Lines | 95 |
Code Lines | 57 |
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 |
||
115 | private static function getEvenMawrCommonParameters() { |
||
116 | global $egMapsDefaultTitle, $egMapsDefaultLabel; |
||
117 | |||
118 | $params = []; |
||
119 | |||
120 | $params['title'] = [ |
||
121 | 'name' => 'title', |
||
122 | 'default' => $egMapsDefaultTitle, |
||
123 | ]; |
||
124 | |||
125 | $params['label'] = [ |
||
126 | 'default' => $egMapsDefaultLabel, |
||
127 | 'aliases' => 'text', |
||
128 | ]; |
||
129 | |||
130 | $params['icon'] = [ |
||
131 | 'default' => '', // TODO: image param |
||
132 | ]; |
||
133 | |||
134 | $params['visitedicon'] = [ |
||
135 | 'default' => '', //TODO: image param |
||
136 | ]; |
||
137 | |||
138 | $params['lines'] = [ |
||
139 | 'type' => 'mapsline', |
||
140 | 'default' => [], |
||
141 | 'delimiter' => ';', |
||
142 | 'islist' => true, |
||
143 | ]; |
||
144 | |||
145 | $params['polygons'] = [ |
||
146 | 'type' => 'mapspolygon', |
||
147 | 'default' => [], |
||
148 | 'delimiter' => ';', |
||
149 | 'islist' => true, |
||
150 | ]; |
||
151 | |||
152 | $params['circles'] = [ |
||
153 | 'type' => 'mapscircle', |
||
154 | 'default' => [], |
||
155 | 'delimiter' => ';', |
||
156 | 'islist' => true, |
||
157 | ]; |
||
158 | |||
159 | $params['rectangles'] = [ |
||
160 | 'type' => 'mapsrectangle', |
||
161 | 'default' => [], |
||
162 | 'delimiter' => ';', |
||
163 | 'islist' => true, |
||
164 | ]; |
||
165 | |||
166 | $params['wmsoverlay'] = [ |
||
167 | 'type' => 'wmsoverlay', |
||
168 | 'default' => false, |
||
169 | 'delimiter' => ' ', |
||
170 | ]; |
||
171 | |||
172 | $params['maxzoom'] = [ |
||
173 | 'type' => 'integer', |
||
174 | 'default' => false, |
||
175 | 'manipulatedefault' => false, |
||
176 | 'dependencies' => 'minzoom', |
||
177 | ]; |
||
178 | |||
179 | $params['minzoom'] = [ |
||
180 | 'type' => 'integer', |
||
181 | 'default' => false, |
||
182 | 'manipulatedefault' => false, |
||
183 | 'lowerbound' => 0, |
||
184 | ]; |
||
185 | |||
186 | $params['copycoords'] = [ |
||
187 | 'type' => 'boolean', |
||
188 | 'default' => false, |
||
189 | ]; |
||
190 | |||
191 | $params['static'] = [ |
||
192 | 'type' => 'boolean', |
||
193 | 'default' => false, |
||
194 | ]; |
||
195 | |||
196 | // Give grep a chance to find the usages: |
||
197 | // maps-displaymap-par-title, maps-displaymap-par-label, maps-displaymap-par-icon, |
||
198 | // maps-displaymap-par-visitedicon, aps-displaymap-par-lines, maps-displaymap-par-polygons, |
||
199 | // maps-displaymap-par-circles, maps-displaymap-par-rectangles, maps-displaymap-par-wmsoverlay, |
||
200 | // maps-displaymap-par-maxzoom, maps-displaymap-par-minzoom, maps-displaymap-par-copycoords, |
||
201 | // maps-displaymap-par-static |
||
202 | foreach ( $params as $name => &$param ) { |
||
203 | if ( !array_key_exists( 'message', $param ) ) { |
||
204 | $param['message'] = 'maps-displaymap-par-' . $name; |
||
205 | } |
||
206 | } |
||
207 | |||
208 | return $params; |
||
209 | } |
||
210 | |||
261 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.