Conditions | 29 |
Paths | > 20000 |
Total Lines | 140 |
Code Lines | 68 |
Lines | 35 |
Ratio | 25 % |
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 |
||
182 | public function Stroke($aStrokeFileName = '') |
||
183 | { |
||
184 | |||
185 | // If the filename is the predefined value = '_csim_special_' |
||
186 | // we assume that the call to stroke only needs to do enough |
||
187 | // to correctly generate the CSIM maps. |
||
188 | // We use this variable to skip things we don't strictly need |
||
189 | // to do to generate the image map to improve performance |
||
190 | // a best we can. Therefor you will see a lot of tests !$_csim in the |
||
191 | // code below. |
||
192 | $_csim = ($aStrokeFileName === _CSIM_SPECIALFILE); |
||
193 | |||
194 | // We need to know if we have stroked the plot in the |
||
195 | // GetCSIMareas. Otherwise the CSIM hasn't been generated |
||
196 | // and in the case of GetCSIM called before stroke to generate |
||
197 | // CSIM without storing an image to disk GetCSIM must call Stroke. |
||
198 | $this->iHasStroked = true; |
||
199 | |||
200 | $n = count($this->plots); |
||
201 | // Set Y-scale |
||
202 | |||
203 | if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { |
||
204 | list($min, $max) = $this->GetPlotsYMinMax($this->plots); |
||
205 | $this->yscale->AutoScale($this->img, 0, $max, $this->len / $this->ytick_factor); |
||
206 | } elseif ($this->yscale->IsSpecified() && |
||
207 | ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) { |
||
208 | |||
209 | // The tick calculation will use the user suplied min/max values to determine |
||
210 | // the ticks. If auto_ticks is false the exact user specifed min and max |
||
211 | // values will be used for the scale. |
||
212 | // If auto_ticks is true then the scale might be slightly adjusted |
||
213 | // so that the min and max values falls on an even major step. |
||
214 | $min = $this->yscale->scale[0]; |
||
215 | $max = $this->yscale->scale[1]; |
||
216 | $this->yscale->AutoScale($this->img, $min, $max, |
||
217 | $this->len / $this->ytick_factor, |
||
218 | $this->yscale->auto_ticks); |
||
219 | } |
||
220 | |||
221 | // Set start position end length of scale (in absolute pixels) |
||
222 | $this->yscale->SetConstants($this->posx, $this->len); |
||
223 | |||
224 | // We need as many axis as there are data points |
||
225 | $nbrpnts = $this->plots[0]->GetCount(); |
||
226 | |||
227 | // If we have no titles just number the axis 1,2,3,... |
||
228 | if ($this->axis_title == null) { |
||
229 | for ($i = 0; $i < $nbrpnts; ++$i) { |
||
230 | $this->axis_title[$i] = $i + 1; |
||
231 | } |
||
232 | } elseif (count($this->axis_title) < $nbrpnts) { |
||
233 | Util\JpGraphError::RaiseL(18007); |
||
234 | // ("Number of titles does not match number of points in plot."); |
||
235 | } |
||
236 | for ($i = 0; $i < $n; ++$i) { |
||
237 | if ($nbrpnts != $this->plots[$i]->GetCount()) { |
||
238 | Util\JpGraphError::RaiseL(18008); |
||
239 | //("Each radar plot must have the same number of data points."); |
||
240 | } |
||
241 | } |
||
242 | |||
243 | if (!$_csim) { |
||
244 | if ($this->background_image != '') { |
||
245 | $this->StrokeFrameBackground(); |
||
246 | } else { |
||
247 | $this->StrokeFrame(); |
||
248 | $this->StrokeBackgroundGrad(); |
||
249 | } |
||
250 | } |
||
251 | $astep = 2 * M_PI / $nbrpnts; |
||
252 | |||
253 | if (!$_csim) { |
||
254 | if ($this->iIconDepth == DEPTH_BACK) { |
||
255 | $this->StrokeIcons(); |
||
256 | } |
||
257 | |||
258 | // Prepare legends |
||
259 | for ($i = 0; $i < $n; ++$i) { |
||
260 | $this->plots[$i]->Legend($this); |
||
261 | } |
||
262 | $this->legend->Stroke($this->img); |
||
263 | $this->footer->Stroke($this->img); |
||
264 | } |
||
265 | |||
266 | if (!$_csim) { |
||
267 | View Code Duplication | if ($this->grid_depth == DEPTH_BACK) { |
|
268 | // Draw axis and grid |
||
269 | for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { |
||
270 | $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); |
||
271 | } |
||
272 | $this->grid->Stroke($this->img, $grid); |
||
273 | } |
||
274 | if ($this->iIconDepth == DEPTH_BACK) { |
||
275 | $this->StrokeIcons(); |
||
276 | } |
||
277 | } |
||
278 | |||
279 | // Plot points |
||
280 | $a = M_PI / 2; |
||
281 | View Code Duplication | for ($i = 0; $i < $n; ++$i) { |
|
282 | $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a); |
||
283 | } |
||
284 | |||
285 | if (!$_csim) { |
||
286 | View Code Duplication | if ($this->grid_depth != DEPTH_BACK) { |
|
287 | // Draw axis and grid |
||
288 | for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { |
||
289 | $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); |
||
290 | } |
||
291 | $this->grid->Stroke($this->img, $grid); |
||
292 | } |
||
293 | |||
294 | $this->StrokeTitles(); |
||
295 | $this->StrokeTexts(); |
||
296 | if ($this->iIconDepth == DEPTH_FRONT) { |
||
297 | $this->StrokeIcons(); |
||
298 | } |
||
299 | } |
||
300 | |||
301 | // Should we do any final image transformation |
||
302 | View Code Duplication | if ($this->iImgTrans && !$_csim) { |
|
303 | $tform = new ImgTrans($this->img->img); |
||
304 | $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, |
||
305 | $this->iImgTransDirection, $this->iImgTransHighQ, |
||
306 | $this->iImgTransMinSize, $this->iImgTransFillColor, |
||
307 | $this->iImgTransBorder); |
||
308 | } |
||
309 | |||
310 | View Code Duplication | if (!$_csim) { |
|
311 | // If the filename is given as the special "__handle" |
||
312 | // then the image handler is returned and the image is NOT |
||
313 | // streamed back |
||
314 | if ($aStrokeFileName == _IMG_HANDLER) { |
||
315 | return $this->img->img; |
||
316 | } else { |
||
317 | // Finally stream the generated picture |
||
318 | $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); |
||
319 | } |
||
320 | } |
||
321 | } |
||
322 | } // Class |
||
323 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: