30 $needle =
' --'.$key2.
'=';
31 if (is_array($args) &&
32 array_key_exists($key1, $args) &&
33 strpos($args[$key1],$needle) !==
false) {
34 $exploded = explode($needle,$args[$key1]);
35 $args[$key1] =
trim($exploded[0]);
36 $args[$key2] =
trim($exploded[1]);
48 if (empty($license) || $license ===
"NOASSERTION") {
52 if (strpos($license,
" OR ") !==
false) {
53 return "(" . $license .
")";
56 $license = preg_replace(
'/[^a-zA-Z0-9\-\_\.\+]/',
'-',$license);
57 if (strpos($license, LicenseRef::SPDXREF_PREFIX) !==
false) {
59 $license = preg_replace(
'/\+$/',
'-or-later', $license);
61 return preg_replace(
'/\+(?!$)/',
'-',$license);
72 foreach ($licenses as $license=>$text) {
85 return array_map(
function ($license)
98 if (!$licenses || !is_array($licenses) ||
sizeof($licenses) == 0) {
103 sort($licenses, SORT_NATURAL | SORT_FLAG_CASE);
105 if (count($licenses) == 3 &&
106 ($index = array_search(
"Dual-license",$licenses)) !==
false) {
107 return $licenses[$index===0?1:0] .
" OR " . $licenses[$index===2?1:2];
108 } elseif (count($licenses) == 3 &&
109 ($index = array_search(LicenseRef::SPDXREF_PREFIX .
"Dual-license", $licenses)) !==
false) {
110 return $licenses[$index===0?1:0] .
" OR " . $licenses[$index===2?1:2];
113 return implode(
" AND ", $licenses);
125 if (!$texts || !is_array($texts) ||
sizeof($texts) == 0) {
129 sort($texts, SORT_NATURAL | SORT_FLAG_CASE);
132 foreach ($texts as $text) {
137 $cleanArray[] = $text;
150 foreach ($licenses as $license) {
151 if (empty($license) || $license ===
"NOASSERTION") {
154 $newList[] = $license;
static implodeLicenses($licenses)
Implode licenses with "AND" or "OR".
static preWorkOnArgsFlp($args, $key1, $key2)
For a given set of arguments assign $args[$key1] and $args[$key2].
static addPrefixOnDemandList($licenses)
Add prefix to license list.
static addPrefixOnDemandKeys($licenses)
Add prefix to license keys.
static cleanTextArray($texts)
static removeEmptyLicenses($licenses)
static addPrefixOnDemand($license)
Add prefix to the license based on SPDX2 standards.
char * trim(char *ptext)
Trimming whitespace.
Namespace used by SPDX2 agent.