function ShowCommand::appendLicenses
Parameters
JsonStructure $json:
Return value
JsonStructure
1 call to ShowCommand::appendLicenses()
- ShowCommand::printPackageInfoAsJson in vendor/
composer/ composer/ src/ Composer/ Command/ ShowCommand.php - Prints package info in JSON format.
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ ShowCommand.php, line 1121
Class
- ShowCommand
- @author Robert Schönthal <seroscho@googlemail.com> @author Jordi Boggiano <j.boggiano@seld.be> @author Jérémy Romey <jeremyFreeAgent> @author Mihai Plasoianu <mihai@plasoianu.de>
Namespace
Composer\CommandCode
private function appendLicenses(array $json, CompletePackageInterface $package) : array {
if ($licenses = $package->getLicense()) {
$spdxLicenses = new SpdxLicenses();
$json['licenses'] = array_map(static function ($licenseId) use ($spdxLicenses) {
$license = $spdxLicenses->getLicenseByIdentifier($licenseId);
// keys: 0 fullname, 1 osi, 2 url
if (!$license) {
return $licenseId;
}
return [
'name' => $license[0],
'osi' => $licenseId,
'url' => $license[2],
];
}, $licenses);
}
return $json;
}