| Conditions | 10 |
| Paths | 6 |
| Total Lines | 33 |
| Code Lines | 28 |
| 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 |
||
| 85 | protected function calculateDimention($image, $request) |
||
| 86 | { |
||
| 87 | $dimention = []; |
||
| 88 | if ($request->has('type')) { |
||
| 89 | if ($request->type == 1 || $request->type == 'Normal') { |
||
| 90 | $dimention['width'] = 600; |
||
| 91 | $dimention['height'] = 600; |
||
| 92 | $dimention['small-width'] = 100; |
||
| 93 | $dimention['small-height'] = 100; |
||
| 94 | } elseif ($request->type == 2 || $request->type == 'Horizontal') { |
||
| 95 | $dimention['width'] = 800; |
||
| 96 | $dimention['height'] = 600; |
||
| 97 | $dimention['small-width'] = 150; |
||
| 98 | $dimention['small-height'] = 100; |
||
| 99 | } elseif ($request->type == 3 || $request->type == 'Vertical') { |
||
| 100 | $dimention['width'] = 600; |
||
| 101 | $dimention['height'] = 800; |
||
| 102 | $dimention['small-width'] = 100; |
||
| 103 | $dimention['small-height'] = 150; |
||
| 104 | } elseif ($request->type == 4 || $request->type == 'Slider') { |
||
| 105 | $dimention['width'] = 1920; |
||
| 106 | $dimention['height'] = 1280; |
||
| 107 | $dimention['small-width'] = 200; |
||
| 108 | $dimention['small-height'] = 100; |
||
| 109 | } |
||
| 110 | } else { |
||
| 111 | $dimention['width'] = 600; |
||
| 112 | $dimention['height'] = 600; |
||
| 113 | $dimention['small-width'] = 100; |
||
| 114 | $dimention['small-height'] = 100; |
||
| 115 | } |
||
| 116 | |||
| 117 | return $dimention; |
||
| 118 | } |
||
| 120 |