commit
0bb7e03696
|
@ -34,7 +34,7 @@ class LicensesCommand extends BaseCommand
|
||||||
->setName('licenses')
|
->setName('licenses')
|
||||||
->setDescription('Shows information about licenses of dependencies.')
|
->setDescription('Shows information about licenses of dependencies.')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
|
new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
|
||||||
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
|
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
|
||||||
))
|
))
|
||||||
->setHelp(
|
->setHelp(
|
||||||
|
@ -113,18 +113,21 @@ EOT
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'summary':
|
case 'summary':
|
||||||
$dependencies = array();
|
$usedLicenses = array();
|
||||||
foreach ($packages as $package) {
|
foreach ($packages as $package) {
|
||||||
$license = $package->getLicense();
|
$license = $package->getLicense();
|
||||||
$licenseName = $license[0];
|
$licenseName = $license[0];
|
||||||
if (!isset($dependencies[$licenseName])) {
|
if (!isset($usedLicenses[$licenseName])) {
|
||||||
$dependencies[$licenseName] = 0;
|
$usedLicenses[$licenseName] = 0;
|
||||||
}
|
}
|
||||||
$dependencies[$licenseName]++;
|
$usedLicenses[$licenseName]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort licenses so that the most used license will appear first
|
||||||
|
arsort($usedLicenses, SORT_NUMERIC);
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($dependencies as $usedLicense => $numberOfDependencies) {
|
foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
|
||||||
$rows[] = array($usedLicense, $numberOfDependencies);
|
$rows[] = array($usedLicense, $numberOfDependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue