| Conditions | 12 |
| Paths | 12 |
| Total Lines | 24 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 23 | public static function getMessage(int $errorCode): string |
||
| 24 | { |
||
| 25 | switch ($errorCode) { |
||
| 26 | case self::OK: |
||
| 27 | return ''; |
||
| 28 | case self::INI_SIZE: |
||
| 29 | case self::FORM_SIZE: |
||
| 30 | return \__('Uploaded file size exceeds maximum file size allowed.'); |
||
| 31 | case self::PARTIAL: |
||
| 32 | return \__('The uploaded file was only partially uploaded.'); |
||
| 33 | case self::NO_FILE: |
||
| 34 | return \__('No file was uploaded.'); |
||
| 35 | case self::TYPE_NOT_ALLOWED: |
||
| 36 | return \__('File type not allowed.'); |
||
| 37 | case self::CANT_WRITE: |
||
| 38 | return \__('Error saving uploaded file.'); |
||
| 39 | case self::IMAGE_TOO_SMALL: |
||
| 40 | return \__('Image is too small.'); |
||
| 41 | case self::IMAGE_WRONG_ASPECT_RATIO: |
||
| 42 | return \__('Image has wrong aspect ratio.'); |
||
| 43 | case self::NO_TMP_DIR: |
||
| 44 | case self::EXTENSION: |
||
| 45 | default: |
||
| 46 | return \__('Upload error.'); |
||
| 47 | } |
||
| 50 |