| Conditions | 6 |
| Paths | 10 |
| Total Lines | 53 |
| Code Lines | 34 |
| 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 |
||
| 120 | private function viewVersionHistory(SymfonyStyle $symfonyStyle, Package $package) |
||
| 121 | { |
||
| 122 | $versions = ['exit']; |
||
| 123 | if (!empty($package->getVersions())) { |
||
| 124 | foreach ($package->getVersions() as $version) { |
||
| 125 | $versions[] = $version->getVersion(); |
||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 129 | $showVersionsHistory = $symfonyStyle->choice('Do you want to view version history?', $versions, 'exit'); |
||
| 130 | |||
| 131 | if ($showVersionsHistory != 'exit') { |
||
| 132 | $header = ['Key', 'Value']; |
||
| 133 | |||
| 134 | $authors = []; |
||
| 135 | /** @var PackageAuthor $author */ |
||
| 136 | foreach ($package->getVersions()->offsetGet($showVersionsHistory)->getAuthors() as $author) { |
||
| 137 | $authors[] = "[" . $author->getRole() . "] " . $author->getName() . " (" . $author->getEmail() . ")"; |
||
| 138 | } |
||
| 139 | |||
| 140 | $source = "[" . $package->getVersions()->offsetGet($showVersionsHistory)->getSource()->getType() . "] "; |
||
| 141 | $source .= $package->getVersions()->offsetGet($showVersionsHistory)->getSource()->getUrl(); |
||
| 142 | |||
| 143 | $dist = "[" . $package->getVersions()->offsetGet($showVersionsHistory)->getDist()->getType() . "] "; |
||
| 144 | $dist .= $package->getVersions()->offsetGet($showVersionsHistory)->getDist()->getUrl(); |
||
| 145 | |||
| 146 | $require = []; |
||
| 147 | /** @var PackageDependency $dependency */ |
||
| 148 | foreach ($package->getVersions()->offsetGet($showVersionsHistory)->getRequire() as $dependency) { |
||
| 149 | $require[] = $dependency->getName() . " => " . $dependency->getVersion(); |
||
| 150 | } |
||
| 151 | |||
| 152 | $body = [ |
||
| 153 | ['version', $package->getVersions()->offsetGet($showVersionsHistory)->getVersion()], |
||
| 154 | ['name', $package->getVersions()->offsetGet($showVersionsHistory)->getName()], |
||
| 155 | ['description', $package->getVersions()->offsetGet($showVersionsHistory)->getDescription()], |
||
| 156 | ['type', $package->getVersions()->offsetGet($showVersionsHistory)->getType()], |
||
| 157 | ['time', $package->getVersions()->offsetGet($showVersionsHistory)->getTime()], |
||
| 158 | ['keywords', implode(', ', $package->getVersions()->offsetGet($showVersionsHistory)->getKeywords())], |
||
| 159 | ['homepage', $package->getVersions()->offsetGet($showVersionsHistory)->getHomePage()], |
||
| 160 | ['version_normalized', $package->getVersions()->offsetGet($showVersionsHistory)->getVersionNormalized()], |
||
| 161 | ['license', $package->getVersions()->offsetGet($showVersionsHistory)->getLicense()], |
||
| 162 | ['authors', implode("\n", $authors)], |
||
| 163 | ['source', $source], |
||
| 164 | ['dist', $dist], |
||
| 165 | ['require', implode("\n", $require)], |
||
| 166 | ]; |
||
| 167 | |||
| 168 | $symfonyStyle->table($header, $body); |
||
| 169 | |||
| 170 | $this->viewVersionHistory($symfonyStyle, $package); |
||
| 171 | } |
||
| 172 | } |
||
| 173 | } |
||
| 174 |