| Conditions | 10 |
| Paths | 13 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 42 | protected function renderIndexObjectColumn(?IndexObject $indexObject): string |
||
| 43 | { |
||
| 44 | if ($indexObject === null) |
||
| 45 | { |
||
| 46 | return '-'; |
||
| 47 | } |
||
| 48 | |||
| 49 | $parts = [ |
||
| 50 | $indexObject->getTypeName(), |
||
| 51 | "mtime: " . ($indexObject->getMtime() === null ? '-' : FilesystemUtility::buildTime($indexObject->getMtime())), |
||
| 52 | "ctime: " . ($indexObject->getCtime() === null ? '-' : FilesystemUtility::buildTime($indexObject->getCtime())), |
||
| 53 | "perms: 0{$indexObject->getPermissionsString()}", |
||
| 54 | ]; |
||
| 55 | |||
| 56 | if ($indexObject->isFile()) |
||
| 57 | { |
||
| 58 | $parts = array_merge($parts, [ |
||
| 59 | "size: " . (($indexObject->getSize() !== null) ? static::formatMemory($indexObject->getSize()) : '-'), |
||
| 60 | "blobId: " . ($indexObject->getBlobId() ?: '-'), |
||
| 61 | "hash(es):" . ($indexObject->getHashes() && $indexObject->getHashes()->count() ? ("\n" . str_replace(', ', "\n", $indexObject->getHashes()->__toString())) : ' -'), |
||
| 62 | ]); |
||
| 63 | } |
||
| 64 | elseif ($indexObject->isLink()) |
||
| 65 | { |
||
| 66 | $parts = array_merge($parts, [ |
||
| 67 | "target: {$indexObject->getLinkTarget()}" |
||
| 68 | ]); |
||
| 69 | } |
||
| 70 | |||
| 71 | return implode("\n", $parts); |
||
| 72 | } |
||
| 73 | } |
||
| 74 |