| Conditions | 18 |
| Paths | 209 |
| Total Lines | 57 |
| Code Lines | 36 |
| 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 |
||
| 49 | protected function prepareDimensions($img, $width, $height, $fit) |
||
| 50 | { |
||
| 51 | if ($width === null && $height === null) { |
||
| 52 | return array('width' => $img->getWidth(), 'height' => $img->getHeight()); |
||
| 53 | } |
||
| 54 | |||
| 55 | if ($width !== null) { |
||
| 56 | $width = Coordinate::fix($width, $img->getWidth()); |
||
| 57 | $rx = $img->getWidth() / $width; |
||
| 58 | } else { |
||
| 59 | $rx = null; |
||
| 60 | } |
||
| 61 | |||
| 62 | if ($height !== null) { |
||
| 63 | $height = Coordinate::fix($height, $img->getHeight()); |
||
| 64 | $ry = $img->getHeight() / $height; |
||
| 65 | } else { |
||
| 66 | $ry = null; |
||
| 67 | } |
||
| 68 | |||
| 69 | if ($rx === null && $ry !== null) { |
||
| 70 | $rx = $ry; |
||
| 71 | $width = round($img->getWidth() / $rx); |
||
| 72 | } |
||
| 73 | |||
| 74 | if ($ry === null && $rx !== null) { |
||
| 75 | $ry = $rx; |
||
| 76 | $height = round($img->getHeight() / $ry); |
||
| 77 | } |
||
| 78 | |||
| 79 | if ($width === 0 || $height === 0) { |
||
| 80 | return array('width' => 0, 'height' => 0); |
||
| 81 | } |
||
| 82 | |||
| 83 | if ($fit == null) { |
||
| 84 | $fit = 'inside'; |
||
| 85 | } |
||
| 86 | |||
| 87 | $dim = array(); |
||
| 88 | |||
| 89 | if ($fit == 'fill') { |
||
| 90 | $dim['width'] = $width; |
||
| 91 | $dim['height'] = $height; |
||
| 92 | } elseif ($fit == 'inside' || $fit == 'outside') { |
||
| 93 | if ($fit == 'inside') { |
||
| 94 | $ratio = ($rx > $ry) ? $rx : $ry; |
||
| 95 | } else { |
||
| 96 | $ratio = ($rx < $ry) ? $rx : $ry; |
||
| 97 | } |
||
| 98 | |||
| 99 | $dim['width'] = round($img->getWidth() / $ratio); |
||
| 100 | $dim['height'] = round($img->getHeight() / $ratio); |
||
| 101 | } else { |
||
| 102 | throw new InvalidFitMethodException("{$fit} is not a valid resize-fit method."); |
||
| 103 | } |
||
| 104 | |||
| 105 | return $dim; |
||
| 106 | } |
||
| 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