Conditions | 13 |
Paths | 10 |
Total Lines | 47 |
Code Lines | 31 |
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 |
||
118 | public function execute($img, $width, $height, $fit, $scale) |
||
119 | { |
||
120 | $dim = $this->prepareDimensions($img, $width, $height, $fit); |
||
121 | |||
122 | if (($scale === 'down' && ($dim['width'] >= $img->getWidth() && $dim['height'] >= $img->getHeight())) || |
||
123 | ($scale === 'up' && ($dim['width'] <= $img->getWidth() && $dim['height'] <= $img->getHeight()))) { |
||
124 | $dim = array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
||
125 | } |
||
126 | |||
127 | if ($dim['width'] <= 0 || $dim['height'] <= 0) { |
||
128 | throw new InvalidResizeDimensionException("Both dimensions must be larger than 0."); |
||
129 | } |
||
130 | |||
131 | if ($img->isTransparent() || $img instanceof PaletteImage) { |
||
132 | $new = PaletteImage::create($dim['width'], $dim['height']); |
||
133 | $new->copyTransparencyFrom($img); |
||
134 | |||
135 | if (!imagecopyresized( |
||
136 | $new->getHandle(), |
||
137 | $img->getHandle(), |
||
138 | 0, 0, 0, 0, |
||
139 | $new->getWidth(), |
||
140 | $new->getHeight(), |
||
141 | $img->getWidth(), |
||
142 | $img->getHeight())) { |
||
143 | throw new GDFunctionResultException("imagecopyresized() returned false"); |
||
144 | } |
||
145 | } else { |
||
146 | $new = TrueColorImage::create($dim['width'], $dim['height']); |
||
147 | $new->alphaBlending(false); |
||
148 | $new->saveAlpha(true); |
||
149 | |||
150 | if (!imagecopyresampled( |
||
151 | $new->getHandle(), |
||
152 | $img->getHandle(), |
||
153 | 0, 0, 0, 0, |
||
154 | $new->getWidth(), |
||
155 | $new->getHeight(), |
||
156 | $img->getWidth(), |
||
157 | $img->getHeight())) { |
||
158 | throw new GDFunctionResultException("imagecopyresampled() returned false"); |
||
159 | } |
||
160 | |||
161 | $new->alphaBlending(true); |
||
162 | } |
||
163 | |||
164 | return $new; |
||
165 | } |
||
167 |
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