Fix licenses command summary to count all licenses of a package
parent
8756f54da0
commit
6ea5b84bd9
|
@ -93,7 +93,7 @@ EOT
|
|||
$tableStyle->setVerticalBorderChar('');
|
||||
}
|
||||
$tableStyle->setCellRowContentFormat('%s ');
|
||||
$table->setHeaders(array('Name', 'Version', 'License'));
|
||||
$table->setHeaders(array('Name', 'Version', 'Licenses'));
|
||||
foreach ($packages as $package) {
|
||||
$table->addRow(array(
|
||||
$package->getPrettyName(),
|
||||
|
@ -124,14 +124,17 @@ EOT
|
|||
case 'summary':
|
||||
$usedLicenses = array();
|
||||
foreach ($packages as $package) {
|
||||
$license = $package instanceof CompletePackageInterface ? $package->getLicense() : array();
|
||||
$licenseName = array_key_exists(0, $license) ? $license[0] : 'none';
|
||||
|
||||
$licenses = $package instanceof CompletePackageInterface ? $package->getLicense() : array();
|
||||
if (count($licenses) === 0) {
|
||||
$licenses[] = 'none';
|
||||
}
|
||||
foreach ($licenses as $licenseName) {
|
||||
if (!isset($usedLicenses[$licenseName])) {
|
||||
$usedLicenses[$licenseName] = 0;
|
||||
}
|
||||
$usedLicenses[$licenseName]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort licenses so that the most used license will appear first
|
||||
arsort($usedLicenses, SORT_NUMERIC);
|
||||
|
|
Loading…
Reference in New Issue