Conditions | 10 |
Paths | 11 |
Total Lines | 32 |
Code Lines | 21 |
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 |
||
37 | public function getStorage(Config $config): IDrivingFile |
||
38 | { |
||
39 | if ($config->drivingFileStorage instanceof IDrivingFile) { |
||
40 | return $config->drivingFileStorage; |
||
41 | } |
||
42 | if ($config->drivingFileStorage instanceof IStorage) { |
||
43 | return new Storage($config->drivingFileStorage, $config->tempDir, $this->getUppLang()); |
||
44 | } |
||
45 | if ($config->drivingFileStorage instanceof CompositeAdapter) { |
||
46 | try { |
||
47 | $ap = new ArrayPath(); |
||
48 | return new Files($config->drivingFileStorage, $ap->setString($config->tempDir)->getArray(), $ap, $this->getUppLang()); |
||
49 | // @codeCoverageIgnoreStart |
||
50 | } catch (PathsException $ex) { |
||
51 | throw new UploadException($ex->getMessage(), $ex->getCode(), $ex); |
||
52 | } |
||
53 | // @codeCoverageIgnoreEnd |
||
54 | } |
||
55 | |||
56 | switch ($config->drivingFileStorage) { |
||
57 | case 'volume': |
||
58 | case self::FORMAT_VOLUME: |
||
59 | return new Volume($config->tempDir, $this->getUppLang()); |
||
60 | case 'client': |
||
61 | case self::FORMAT_CLIENT: |
||
62 | return new Client($this->getUppLang()); |
||
63 | default: |
||
64 | if (is_string($config->drivingFileStorage)) { |
||
65 | return new Volume($config->drivingFileStorage, $this->getUppLang()); |
||
66 | } |
||
67 | |||
68 | throw new UploadException($this->getUppLang()->uppDriveFileStorageNotSet()); |
||
69 | } |
||
72 |