31 $needle =
' --'.$key2.
'=';
32 if (is_array($args) &&
33 array_key_exists($key1, $args) &&
34 strpos($args[$key1],$needle) !==
false) {
35 $exploded = explode($needle,$args[$key1]);
36 $args[$key1] =
trim($exploded[0]);
37 $args[$key2] =
trim($exploded[1]);
49 if (empty($license) || $license ===
"NOASSERTION") {
53 if (strpos($license,
" OR ") !==
false) {
54 return "(" . $license .
")";
57 $license = preg_replace(
'/[^a-zA-Z0-9\-\_\.\+]/',
'-',$license);
58 if (strpos($license, LicenseRef::SPDXREF_PREFIX) !==
false) {
60 $license = preg_replace(
'/\+$/',
'-or-later', $license);
62 return preg_replace(
'/\+(?!$)/',
'-',$license);
73 foreach ($licenses as $license=>$text) {
86 return array_map(
function ($license)
99 if (!$licenses || !is_array($licenses) ||
sizeof($licenses) == 0) {
104 sort($licenses, SORT_NATURAL | SORT_FLAG_CASE);
106 if (count($licenses) == 3) {
107 foreach ($licenses as $index => $lic) {
111 return $licenses[$index===0?1:0] .
" OR " . $licenses[$index===2?1:2];
115 return implode(
" AND ", $licenses);
126 if (!$texts || !is_array($texts) ||
sizeof($texts) == 0) {
130 sort($texts, SORT_NATURAL | SORT_FLAG_CASE);
133 foreach ($texts as $text) {
138 $cleanArray[] = $text;
151 foreach ($licenses as $license) {
152 if (empty($license) || $license ===
"NOASSERTION") {
155 $newList[] = $license;
static stringStartsWith($haystack, $needle)
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 implodeLicenses($licenses)
Implode licenses with "AND" or "OR".
static addPrefixOnDemandKeys($licenses)
Add prefix to license keys.
static addPrefixOnDemand($license)
Add prefix to the license based on SPDX2 standards.
static removeEmptyLicenses($licenses)
static cleanTextArray($texts)
char * trim(char *ptext)
Trimming whitespace.
Namespace used by SPDX2 agent.