Conditions | 11 |
Paths | 80 |
Total Lines | 47 |
Code Lines | 27 |
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 |
||
48 | public function execute($img, $left, $top, $width, $height) |
||
49 | { |
||
50 | $width = Coordinate::fix($width, $img->getWidth(), $width); |
||
51 | $height = Coordinate::fix($height, $img->getHeight(), $height); |
||
52 | $left = Coordinate::fix($left, $img->getWidth(), $width); |
||
53 | $top = Coordinate::fix($top, $img->getHeight(), $height); |
||
54 | |||
55 | if ($left < 0) { |
||
56 | $width = $left + $width; |
||
57 | $left = 0; |
||
58 | } |
||
59 | |||
60 | if ($width > $img->getWidth() - $left) { |
||
61 | $width = $img->getWidth() - $left; |
||
62 | } |
||
63 | |||
64 | if ($top < 0) { |
||
65 | $height = $top + $height; |
||
66 | $top = 0; |
||
67 | } |
||
68 | |||
69 | if ($height > $img->getHeight() - $top) { |
||
70 | $height = $img->getHeight() - $top; |
||
71 | } |
||
72 | |||
73 | if ($width <= 0 || $height <= 0) { |
||
74 | throw new Exception("Can't crop outside of an image."); |
||
75 | } |
||
76 | |||
77 | $new = $img->doCreate($width, $height); |
||
78 | |||
79 | if ($img->isTransparent() || $img instanceof PaletteImage) { |
||
80 | $new->copyTransparencyFrom($img); |
||
81 | |||
82 | if (!imagecopyresized($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) { |
||
83 | throw new GDFunctionResultException("imagecopyresized() returned false"); |
||
84 | } |
||
85 | } else { |
||
86 | $new->alphaBlending(false); |
||
87 | $new->saveAlpha(true); |
||
88 | |||
89 | if (!imagecopyresampled($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) { |
||
90 | throw new GDFunctionResultException("imagecopyresampled() returned false"); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | return $new; |
||
95 | } |
||
97 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths