Conditions | 14 |
Paths | 10 |
Total Lines | 31 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
73 | private function validateDimension(): void |
||
74 | { |
||
75 | if ($this->isAudioFormat()) { |
||
76 | return; |
||
77 | } |
||
78 | |||
79 | if ($this->mode === LaruploadMediaStyle::SCALE_HEIGHT) { |
||
80 | if ($this->width === null or $this->width === 0) { |
||
81 | throw new Exception( |
||
82 | 'Width is required when you are in SCALE_HEIGHT mode' |
||
83 | ); |
||
84 | } |
||
85 | } |
||
86 | else if ($this->mode === LaruploadMediaStyle::SCALE_WIDTH) { |
||
87 | if ($this->height === null or $this->height === 0) { |
||
88 | throw new Exception( |
||
89 | 'Height is required when you are in SCALE_WIDTH mode' |
||
90 | ); |
||
91 | } |
||
92 | } |
||
93 | else if (in_array($this->mode, [LaruploadMediaStyle::CROP, LaruploadMediaStyle::FIT])) { |
||
94 | if (!$this->width or !$this->height) { |
||
95 | throw new Exception( |
||
96 | 'Width and Height are required when you are in CROP/FIT mode' |
||
97 | ); |
||
98 | } |
||
99 | } |
||
100 | else if ($this->mode === LaruploadMediaStyle::AUTO) { |
||
101 | if (!$this->width and !$this->height) { |
||
102 | throw new Exception( |
||
103 | 'Width and height are required when you are in auto mode' |
||
104 | ); |
||
109 |