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 if ($this->obligations ===
null) {
222 $obligationList = [];
223 foreach ($this->obligations as $obligation) {
224 $obligationList[] = $obligation->getArray();
226 return $obligationList;
282 if (!is_null($risk)) {
283 $this->risk = intval($risk);
295 $this->isCandidate = filter_var(
$isCandidate, FILTER_VALIDATE_BOOLEAN);
305 $this->obligations = [];
307 $this->obligations =
null;
321 if ($this->obligations ===
null) {
322 $this->obligations = [];
324 $this->obligations[] = $obligation;
333 $this->mergeRequest = filter_var(
$mergeRequest, FILTER_VALIDATE_BOOLEAN);
344 $inputKeys = array_keys($inputLicense);
345 $intersectKeys = array_intersect($inputKeys, self::ALLOWED_KEYS);
346 if (count($inputKeys) > 0 && count($intersectKeys) != count($inputKeys)) {
349 if (array_search(
'shortName', $inputKeys) ===
false) {
353 if (array_key_exists(
'shortName', $inputLicense)) {
354 $newLicense->setShortName($inputLicense[
'shortName']);
356 if (array_key_exists(
'fullName', $inputLicense)) {
357 $newLicense->setFullName($inputLicense[
'fullName']);
359 if (array_key_exists(
'text', $inputLicense)) {
360 $newLicense->setText($inputLicense[
'text']);
362 if (array_key_exists(
'url', $inputLicense)) {
363 $newLicense->setUrl($inputLicense[
'url']);
365 if (array_key_exists(
'risk', $inputLicense)) {
366 $newLicense->setRisk($inputLicense[
'risk']);
368 if (array_key_exists(
'isCandidate', $inputLicense)) {
369 $newLicense->setIsCandidate($inputLicense[
'isCandidate']);
371 if (array_key_exists(
'mergeRequest', $inputLicense)) {
372 $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)