/** * Convert the data of a complete package to the passed json array. * * @param CompletePackageInterface $package The package to process. * * @param JsonArray $data The json array to push the data to. * * @return void */ private function convertCompletePackage(CompletePackageInterface $package, $data) { $data->set('description', $package->getDescription()); $data->set('license', $package->getLicense()); if ($keywords = $package->getKeywords()) { $data->set('keywords', $keywords); } if ($homepage = $package->getHomepage()) { $data->set('homepage', $homepage); } if ($authors = $package->getAuthors()) { $data->set('authors', $authors); } if ($support = $package->getSupport()) { $data->set('support', $support); } if ($extra = $package->getExtra()) { $data->set('extra', $extra); } $data->set('abandoned', $package->isAbandoned()); if ($package->isAbandoned()) { $data->set('replacement', $package->getReplacementPackage()); } }
/** * Prints the licenses of a package with metadata * * @param CompletePackageInterface $package */ protected function printLicenses(CompletePackageInterface $package) { $spdxLicenses = new SpdxLicenses(); $licenses = $package->getLicense(); $io = $this->getIO(); foreach ($licenses as $licenseId) { $license = $spdxLicenses->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url if (!$license) { $out = $licenseId; } else { // is license OSI approved? if ($license[1] === true) { $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]); } else { $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]); } } $io->write('<info>license</info> : ' . $out); } }