diff --git a/src/spdx2/agent/spdx2utils.php b/src/spdx2/agent/spdx2utils.php index 1a096e8d..d41c608a 100644 --- a/src/spdx2/agent/spdx2utils.php +++ b/src/spdx2/agent/spdx2utils.php @@ -1,125 +1,126 @@ $text) { $ret[self::addPrefixOnDemand($license, $spdxValidityChecker)] = $text; } return $ret; } static public function addPrefixOnDemandList($licenses, $spdxValidityChecker = null) { $ret = array(); foreach($licenses as $license) { $ret[] = self::addPrefixOnDemand($license, $spdxValidityChecker); } return $ret; } /** * @param string[] $licenses * @param callable $spdxValidityChecker * * @return string */ static public function implodeLicenses($licenses, $spdxValidityChecker = null) { if(!$licenses || !is_array($licenses) || sizeof($licenses) == 0) { return ""; } $licenses = array_map(function ($license) use ($spdxValidityChecker) { return SpdxTwoUtils::addPrefixOnDemand($license, $spdxValidityChecker); },$licenses); sort($licenses, SORT_NATURAL | SORT_FLAG_CASE); if(count($licenses) == 3 && ($index = array_search("Dual-license",$licenses)) !== false) { return $licenses[$index===0?1:0] . " OR " . $licenses[$index===2?1:2]; } elseif(count($licenses) == 3 && ($index = array_search(self::$prefix . "Dual-license",$licenses)) !== false) { return $licenses[$index===0?1:0] . " OR " . $licenses[$index===2?1:2]; } else { // Add prefixes where needed, enclose statments containing ' OR ' with parantheses return implode(" AND ", $licenses); } } }