| Conditions | 12 | 
| Paths | 12 | 
| Total Lines | 42 | 
| Code Lines | 38 | 
| 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 | ||
| 53 | public function api($method) | ||
| 54 |     { | ||
| 55 |         switch ($method) { | ||
| 56 | case 'info': | ||
| 57 | $api = new Api\Info($this); | ||
| 58 | break; | ||
| 59 | case 'supported-languages': | ||
| 60 | $api = new Api\SupportedLanguages($this); | ||
| 61 | break; | ||
| 62 | case 'status': | ||
| 63 | $api = new Api\Status($this); | ||
| 64 | break; | ||
| 65 | case 'download': | ||
| 66 | $api = new Api\Download($this); | ||
| 67 | break; | ||
| 68 | case 'add-file': | ||
| 69 | $api = new Api\AddFile($this); | ||
| 70 | break; | ||
| 71 | case 'update-file': | ||
| 72 | $api = new Api\UpdateFile($this); | ||
| 73 | break; | ||
| 74 | case 'delete-file': | ||
| 75 | $api = new Api\DeleteFile($this); | ||
| 76 | break; | ||
| 77 | case 'export': | ||
| 78 | $api = new Api\Export($this); | ||
| 79 | break; | ||
| 80 | case 'add-directory': | ||
| 81 | $api = new Api\AddDirectory($this); | ||
| 82 | break; | ||
| 83 | case 'delete-directory': | ||
| 84 | $api = new Api\DeleteDirectory($this); | ||
| 85 | break; | ||
| 86 | case 'upload-translation': | ||
| 87 | $api = new Api\UploadTranslation($this); | ||
| 88 | break; | ||
| 89 | default: | ||
| 90 |                 throw new \InvalidArgumentException(sprintf('Undefined api method "%s"', $method)); | ||
| 91 | } | ||
| 92 | |||
| 93 | return $api; | ||
| 94 | } | ||
| 95 | |||
| 124 |