Conditions | 11 |
Paths | 18 |
Total Lines | 81 |
Code Lines | 49 |
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 |
||
20 | private function imageResize($image, $width, $height = null, $mode = 'expand', $quality = 85) { |
||
21 | if($height == null && $mode == 'expand') { |
||
22 | $height = $width; |
||
23 | } |
||
24 | |||
25 | $img = Image::make($image->getRealPath()); |
||
26 | // $img = $image; |
||
27 | |||
28 | $margin = 0; |
||
29 | |||
30 | $img_width = $img->width(); |
||
31 | $img_height = $img->height(); |
||
32 | |||
33 | /* |
||
34 | * canvas |
||
35 | */ |
||
36 | $dimension = $width; |
||
37 | $desire_width = $width; |
||
38 | $desire_height = $height; |
||
39 | |||
40 | $vertical = ($img_width < $img_height); |
||
41 | $horizontal = ($img_width > $img_height); |
||
42 | $square = ($img_width = $img_height); |
||
43 | |||
44 | if($mode == 'expand') { |
||
45 | if ($vertical) { |
||
46 | $top = $bottom = $margin; |
||
47 | $newHeight = ($dimension) - ($bottom + $top); |
||
48 | $img->resize(null, $newHeight, function ($constraint) { |
||
49 | $constraint->aspectRatio(); |
||
50 | }); |
||
51 | |||
52 | } else if ($horizontal) { |
||
53 | $right = $left = $margin; |
||
54 | $newWidth = ($dimension) - ($right + $left); |
||
55 | $img->resize($newWidth, null, function ($constraint) { |
||
56 | $constraint->aspectRatio(); |
||
57 | }); |
||
58 | |||
59 | } else if ($square) { |
||
60 | $right = $left = $margin; |
||
61 | $newWidth = ($dimension) - ($left + $right); |
||
62 | $img->resize($newWidth, null, function ($constraint) { |
||
63 | $constraint->aspectRatio(); |
||
64 | }); |
||
65 | |||
66 | } |
||
67 | |||
68 | $img->resizeCanvas($dimension, $dimension, 'center', false, '#ffffff'); |
||
69 | $img->encode('jpg', $quality); |
||
70 | |||
71 | } else if($mode == 'constrain') { |
||
72 | if ($vertical) { |
||
73 | $top = $bottom = $margin; |
||
74 | $newHeight = ($desire_height) - ($bottom + $top); |
||
75 | $img->resize(null, $newHeight, function ($constraint) { |
||
76 | $constraint->aspectRatio(); |
||
77 | }); |
||
78 | |||
79 | } else if ($horizontal) { |
||
80 | $right = $left = $margin; |
||
81 | $newWidth = ($desire_width) - ($right + $left); |
||
82 | $img->resize($newWidth, null, function ($constraint) { |
||
83 | $constraint->aspectRatio(); |
||
84 | }); |
||
85 | |||
86 | } else if ($square) { |
||
87 | $right = $left = $margin; |
||
88 | $newWidth = ($desire_width) - ($left + $right); |
||
89 | $img->resize($newWidth, null, function ($constraint) { |
||
90 | $constraint->aspectRatio(); |
||
91 | }); |
||
92 | |||
93 | } |
||
94 | |||
95 | $img->resizeCanvas($desire_width, $desire_height, 'center', false, '#ffffff'); |
||
96 | $img->encode('jpg', $quality); |
||
97 | } |
||
98 | |||
99 | |||
100 | return $img; |
||
101 | // $img->save(public_path("storage/{$token}/{$origFilename}")); |
||
103 | } |
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