41 $needle =
' --'.$key2.
'=';
42 if (is_array($args) &&
43 array_key_exists($key1, $args) &&
44 strpos($args[$key1],$needle) !==
false) {
45 $exploded = explode($needle,$args[$key1]);
46 $args[$key1] =
trim($exploded[0]);
47 $args[$key2] =
trim($exploded[1]);
60 if (empty($license) || $license ===
"NOASSERTION") {
64 if (strpos($license,
" OR ") !==
false) {
65 return "(" . $license .
")";
68 if ($spdxValidityChecker === null ||
69 (is_callable($spdxValidityChecker) &&
70 call_user_func($spdxValidityChecker, $license))) {
76 $license = preg_replace(
'/[^a-zA-Z0-9\-\_\.\+]/',
'-',$license);
77 $license = preg_replace(
'/\+(?!$)/',
'-',$license);
78 return self::$prefix . $license;
90 foreach ($licenses as $license=>$text) {
91 $ret[self::addPrefixOnDemand($license, $spdxValidityChecker)] = $text;
104 return array_map(
function ($license) use ($spdxValidityChecker)
118 if (!$licenses || !is_array($licenses) ||
sizeof($licenses) == 0) {
122 $licenses = self::addPrefixOnDemandList($licenses, $spdxValidityChecker);
123 sort($licenses, SORT_NATURAL | SORT_FLAG_CASE);
125 if (count($licenses) == 3 &&
126 ($index = array_search(
"Dual-license",$licenses)) !==
false) {
127 return $licenses[$index===0?1:0] .
" OR " . $licenses[$index===2?1:2];
128 } elseif (count($licenses) == 3 &&
129 ($index = array_search(self::$prefix .
"Dual-license",$licenses)) !==
false) {
130 return $licenses[$index===0?1:0] .
" OR " . $licenses[$index===2?1:2];
133 return implode(
" AND ", $licenses);
static preWorkOnArgsFlp($args, $key1, $key2)
For a given set of arguments assign $args[$key1] and $args[$key2].
static addPrefixOnDemand($license, $spdxValidityChecker=null)
Add prefix to the license based on SPDX2 standards.
Namespace used by SPDX2 agent.
static addPrefixOnDemandKeys($licenses, $spdxValidityChecker=null)
Add prefix to license keys.
static addPrefixOnDemandList($licenses, $spdxValidityChecker=null)
Add prefix to license list.
static $prefix
Prefix to be used.
static implodeLicenses($licenses, $spdxValidityChecker=null)
Implode licenses with "AND" or "OR".
char * trim(char *ptext)
Trimming whitespace.