Conditions | 10 |
Paths | 8 |
Total Lines | 16 |
Code Lines | 11 |
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 |
||
54 | protected function getActualValue(): string { |
||
55 | $fileName = $this->path === null ? '' : basename($this->path); |
||
56 | if ($fileName === '' && (!$this->storage->isLocal() || $this->storage->instanceOfStorage(Local::class))) { |
||
57 | // Return the mountpoint name of external storages that are not mounted as user home |
||
58 | $mountPoints = $this->mountManager->findByStorageId($this->storage->getId()); |
||
59 | if (empty($mountPoints) || $mountPoints[0]->getMountType() !== 'external') { |
||
60 | return $fileName; |
||
61 | } |
||
62 | $mountPointPath = rtrim($mountPoints[0]->getMountPoint(), '/'); |
||
63 | $mountPointPieces = explode('/', $mountPointPath); |
||
64 | $mountPointName = array_pop($mountPointPieces); |
||
65 | if (!empty($mountPointName) && $mountPointName !== 'files' && count($mountPointPieces) !== 2) { |
||
66 | return $mountPointName; |
||
67 | } |
||
68 | } |
||
69 | return $fileName; |
||
70 | } |
||
94 |