| Conditions | 11 | 
| Paths | 9 | 
| Total Lines | 40 | 
| Code Lines | 12 | 
| Lines | 0 | 
| Ratio | 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  | 
            ||
| 34 | 		public static function save(string $name, string $dir_name) { | 
            ||
| 35 | |||
| 36 | if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) return false;  | 
            ||
| 37 | |||
| 38 | # Check for demo mode  | 
            ||
| 39 | |||
| 40 | if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION';  | 
            ||
| 41 | |||
| 42 | # Check for upload errors  | 
            ||
| 43 | |||
| 44 | if ($file['error'] !== UPLOAD_ERR_OK) return self::translateError($file['error']);  | 
            ||
| 45 | |||
| 46 | # Check size  | 
            ||
| 47 | |||
| 48 | if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) return 'UPLOADER_ERROR_SIZE';  | 
            ||
| 49 | |||
| 50 | # Check file extension  | 
            ||
| 51 | |||
| 52 | $extensions = ['php', 'phtml', 'php3', 'php4', 'php5', 'phps'];  | 
            ||
| 53 | |||
| 54 | if (in_array(Explorer::extension($file['name'], false), $extensions)) return 'UPLOADER_ERROR_TYPE';  | 
            ||
| 55 | |||
| 56 | # Check target directory  | 
            ||
| 57 | |||
| 58 | if (!Explorer::isDir($dir_name)) return 'UPLOADER_ERROR_DIR';  | 
            ||
| 59 | |||
| 60 | # Check target file  | 
            ||
| 61 | |||
| 62 | $file_name = ($dir_name . '/' . basename($file['name']));  | 
            ||
| 63 | |||
| 64 | if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS';  | 
            ||
| 65 | |||
| 66 | # Save uploaded file  | 
            ||
| 67 | |||
| 68 | if (!@move_uploaded_file($file['tmp_name'], $file_name)) return 'UPLOADER_ERROR_SAVE';  | 
            ||
| 69 | |||
| 70 | # ------------------------  | 
            ||
| 71 | |||
| 72 | return true;  | 
            ||
| 73 | }  | 
            ||
| 74 | |||
| 89 |