12 namespace Fossology\UI\Api\Models;
25 const ALLOWED_KEYS = [
'shortName',
'fullName',
'text',
'url',
'risk',
26 'isCandidate',
'mergeRequest'];
96 $this->
id = intval(
$id);
104 $this->mergeRequest =
false;
113 return json_encode($this->
getArray());
123 'id' => $this->
getId(),
131 if ($this->obligations !==
null) {
152 if ($this->shortName ===
null) {
164 if ($this->fullName ===
null) {
176 if ($this->text ===
null) {
188 if ($this->url ===
null) {
218 $obligationList = [];
219 foreach ($this->obligations as $obligation) {
220 $obligationList[] = $obligation->getArray();
222 return $obligationList;
278 if (!is_null($risk)) {
279 $this->risk = intval($risk);
291 $this->isCandidate = filter_var(
$isCandidate, FILTER_VALIDATE_BOOLEAN);
301 $this->obligations = [];
303 $this->obligations =
null;
317 if ($this->obligations ===
null) {
318 $this->obligations = [];
320 $this->obligations[] = $obligation;
329 $this->mergeRequest = filter_var(
$mergeRequest, FILTER_VALIDATE_BOOLEAN);
340 $inputKeys = array_keys($inputLicense);
341 $intersectKeys = array_intersect($inputKeys, self::ALLOWED_KEYS);
342 if (count($inputKeys) > 0 && count($intersectKeys) != count($inputKeys)) {
345 if (array_search(
'shortName', $inputKeys) ===
false) {
349 if (array_key_exists(
'shortName', $inputLicense)) {
350 $newLicense->setShortName($inputLicense[
'shortName']);
352 if (array_key_exists(
'fullName', $inputLicense)) {
353 $newLicense->setFullName($inputLicense[
'fullName']);
355 if (array_key_exists(
'text', $inputLicense)) {
356 $newLicense->setText($inputLicense[
'text']);
358 if (array_key_exists(
'url', $inputLicense)) {
359 $newLicense->setUrl($inputLicense[
'url']);
361 if (array_key_exists(
'risk', $inputLicense)) {
362 $newLicense->setRisk($inputLicense[
'risk']);
364 if (array_key_exists(
'isCandidate', $inputLicense)) {
365 $newLicense->setIsCandidate($inputLicense[
'isCandidate']);
367 if (array_key_exists(
'mergeRequest', $inputLicense)) {
368 $newLicense->setMergeRequest($inputLicense[
'mergeRequest']);
setObligations($obligations)
addObligation($obligation)
setIsCandidate($isCandidate)
setMergeRequest($mergeRequest)
static parseFromArray($inputLicense)
__construct( $id, $shortName="", $fullName="", $text="", $url="", $obligations=null, $risk=null, $isCandidate=false)
if(! defined('ENT_SUBSTITUTE')) convertToUTF8($content, $toHTML=true)