From fd46c7e4bae9ff10a2fbf8956bba38354be5f816 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 16 Mar 2016 11:04:37 +0100 Subject: [PATCH] Reduce line length --- src/Composer/Command/ShowCommand.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 6d6871b3b..fff5a77ad 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -243,11 +243,13 @@ EOT foreach ($packages[$type] as $package) { if (is_object($package)) { $nameLength = max($nameLength, strlen($package->getPrettyName())); - $versionLength = max($versionLength, strlen($package->getFullPrettyVersion())); - if ($showLatest) { - $latestPackage = $this->findLatestPackages($package->getName()); - $latestPackages[$package->getPrettyName()] = $latestPackage; - $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); + if ($showVersion) { + $versionLength = max($versionLength, strlen($package->getFullPrettyVersion())); + if ($showLatest) { + $latestPackage = $this->findLatestPackages($package->getName()); + $latestPackages[$package->getPrettyName()] = $latestPackage; + $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); + } } } else { $nameLength = max($nameLength, $package); @@ -270,8 +272,8 @@ EOT $writePath = !$input->getOption('name-only') && $input->getOption('path'); $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion && ($nameLength + $versionLength + 3 <= $width); - $writeLatest = !$input->getOption('name-only') && !$input->getOption('path') && $showLatest && ($nameLength + ($showVersion ? $versionLength : 0) + $latestLength + 3 <= $width); - $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + ($showVersion ? $versionLength : 0) + ($showLatest ? $latestLength : 0) + 24 <= $width); + $writeLatest = $writeVersion && $showLatest && ($nameLength + $versionLength + $latestLength + 3 <= $width); + $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + $versionLength + $latestLength + 24 <= $width); foreach ($packages[$type] as $package) { if (is_object($package)) { $io->write($indent . str_pad($package->getPrettyName(), $nameLength, ' '), false); @@ -293,7 +295,10 @@ EOT if ($writeDescription) { $description = strtok($package->getDescription(), "\r\n"); - $remaining = $width - $nameLength - $versionLength - ($writeLatest ? $latestLength : 0) - 4; + $remaining = $width - $nameLength - $versionLength - 4; + if ($writeLatest) { + $remaining -= $latestLength; + } if (strlen($description) > $remaining) { $description = substr($description, 0, $remaining - 3) . '...'; }