FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Analysis.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2017 Siemens AG
4  SPDX-FileCopyrightText: © 2021 Orange by Piotr Pszczola <piotr.pszczola@orange.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 namespace Fossology\UI\Api\Models;
15 
20 class Analysis
21 {
26  private $bucket;
31  private $copyright;
36  private $ecc;
41  private $keyword;
46  private $mimetype;
51  private $monk;
56  private $nomos;
61  private $ojo;
66  private $scanoss;
71  private $reso;
76  private $pkgagent;
81  private $ipra;
91  private $compatibility;
96  private $kotoba;
97 
116  public function __construct($bucket = false, $copyright = false, $ecc = false, $keyword = false,
117  $mimetype = false, $monk = false, $nomos = false, $ojo = false, $reso = false, $pkgagent = false, $compatibility = false, $scanoss = false, $ipra = false, $softwareHeritage = false, $kotoba = false)
118  {
119  $this->bucket = $bucket;
120  $this->copyright = $copyright;
121  $this->ecc = $ecc;
122  $this->keyword = $keyword;
123  $this->mimetype = $mimetype;
124  $this->monk = $monk;
125  $this->nomos = $nomos;
126  $this->ojo = $ojo;
127  $this->scanoss = $scanoss;
128  $this->reso = $reso;
129  $this->pkgagent = $pkgagent;
130  $this->ipra = $ipra;
131  $this->softwareHeritage = $softwareHeritage;
132  $this->compatibility = $compatibility;
133  $this->kotoba = $kotoba;
134  }
135 
141  private function setBooleanProperties($array, $propertyMap)
142  {
143  foreach ($propertyMap as $key => $property) {
144  if (array_key_exists($key, $array)) {
145  $this->$property = filter_var($array[$key], FILTER_VALIDATE_BOOLEAN);
146  }
147  }
148  }
149 
155  public function setUsingArray($analysisArray, $version = ApiVersion::V1)
156  {
157  $propertyMap = [
158  'bucket' => 'bucket',
159  ($version == ApiVersion::V2 ? 'copyrightEmailAuthor' : 'copyright_email_author') => 'copyright',
160  'ecc' => 'ecc',
161  'keyword' => 'keyword',
162  'mime' => 'mimetype',
163  'monk' => 'monk',
164  'nomos' => 'nomos',
165  'ojo' => 'ojo',
166  'scanoss' => 'scanoss',
167  'reso' => 'reso',
168  ($version == ApiVersion::V2 ? "pkgagent" : "package") => 'pkgagent',
169  ($version == ApiVersion::V2 ? 'ipra' : 'patent') => 'ipra',
170  ($version == ApiVersion::V2 ? 'softwareHeritage' : "heritage") => 'softwareHeritage',
171  'compatibility' => 'compatibility',
172  ($version == ApiVersion::V2 ? 'kotoba' : 'kotoba_bulk') => 'kotoba'
173  ];
174 
175  $this->setBooleanProperties($analysisArray, $propertyMap);
176  return $this;
177  }
178 
184  public function setUsingString($analysisString)
185  {
186  $propertyMap = [
187  'bucket' => 'bucket',
188  'copyright' => 'copyright',
189  'ecc' => 'ecc',
190  'keyword' => 'keyword',
191  'mimetype' => 'mimetype',
192  'monk' => 'monk',
193  'nomos' => 'nomos',
194  'ojo' => 'ojo',
195  'scanoss' => 'scanoss',
196  'reso' => 'reso',
197  'pkgagent' => 'pkgagent',
198  'ipra' => 'ipra',
199  'softwareHeritage' => 'softwareHeritage',
200  'compatibility' => 'compatibility',
201  'kotoba' => 'kotoba'
202  ];
203 
204  foreach ($propertyMap as $key => $property) {
205  if (stristr($analysisString, $key)) {
206  $this->$property = true;
207  }
208  }
209  return $this;
210  }
211 
213 
216  public function getBucket()
217  {
218  return $this->bucket;
219  }
220 
224  public function getCopyright()
225  {
226  return $this->copyright;
227  }
228 
232  public function getEcc()
233  {
234  return $this->ecc;
235  }
236 
240  public function getKeyword()
241  {
242  return $this->keyword;
243  }
244 
248  public function getMime()
249  {
250  return $this->mimetype;
251  }
252 
256  public function getMonk()
257  {
258  return $this->monk;
259  }
260 
264  public function getNomos()
265  {
266  return $this->nomos;
267  }
268 
272  public function getOjo()
273  {
274  return $this->ojo;
275  }
276 
280  public function getScanoss()
281  {
282  return $this->scanoss;
283  }
284 
288  public function getReso()
289  {
290  return $this->reso;
291  }
292 
296  public function getPkgagent()
297  {
298  return $this->pkgagent;
299  }
300 
304  public function getIpra()
305  {
306  return $this->ipra;
307  }
308 
312  public function getSoftwareHeritage()
313  {
315  }
316 
320  public function getCompatibility()
321  {
322  return $this->compatibility;
323  }
324 
328  public function getkotoba()
329  {
330  return $this->kotoba;
331  }
332 
334 
337  public function setBucket($bucket)
338  {
339  $this->bucket = filter_var($bucket, FILTER_VALIDATE_BOOLEAN);
340  }
341 
345  public function setCopyright($copyright)
346  {
347  $this->copyright = filter_var($copyright, FILTER_VALIDATE_BOOLEAN);
348  }
349 
353  public function setEcc($ecc)
354  {
355  $this->ecc = filter_var($ecc, FILTER_VALIDATE_BOOLEAN);
356  }
357 
361  public function setKeyword($keyword)
362  {
363  $this->keyword = filter_var($keyword, FILTER_VALIDATE_BOOLEAN);
364  }
365 
369  public function setMime($mime)
370  {
371  $this->mimetype = filter_var($mime, FILTER_VALIDATE_BOOLEAN);
372  }
373 
377  public function setMonk($monk)
378  {
379  $this->monk = filter_var($monk, FILTER_VALIDATE_BOOLEAN);
380  }
381 
385  public function setNomos($nomos)
386  {
387  $this->nomos = filter_var($nomos, FILTER_VALIDATE_BOOLEAN);
388  }
389 
393  public function setOjo($ojo)
394  {
395  $this->ojo = filter_var($ojo, FILTER_VALIDATE_BOOLEAN);
396  }
397 
401  public function setScanoss($scanoss)
402  {
403  $this->scanoss = filter_var($scanoss, FILTER_VALIDATE_BOOLEAN);
404  }
405 
409  public function setReso($reso)
410  {
411  $this->reso = filter_var($reso, FILTER_VALIDATE_BOOLEAN);
412  }
413 
417  public function setPkgagent($pkgagent)
418  {
419  $this->pkgagent = filter_var($pkgagent, FILTER_VALIDATE_BOOLEAN);
420  }
421 
425  public function setIpra($ipra)
426  {
427  $this->ipra = filter_var($ipra, FILTER_VALIDATE_BOOLEAN);
428  }
429 
434  {
435  $this->softwareHeritage = filter_var($softwareHeritage, FILTER_VALIDATE_BOOLEAN);
436  }
437 
442  {
443  $this->compatibility = filter_var($compatibility, FILTER_VALIDATE_BOOLEAN);
444  }
445 
449  public function setkotoba($kotoba)
450  {
451  $this->kotoba = filter_var($kotoba, FILTER_VALIDATE_BOOLEAN);
452  }
453 
458  public function getArray($version = ApiVersion::V1)
459  {
460  if ($version == ApiVersion::V2) {
461  return [
462  "bucket" => $this->bucket,
463  "copyrightEmailAuthor" => $this->copyright,
464  "ecc" => $this->ecc,
465  "keyword" => $this->keyword,
466  "mimetype" => $this->mimetype,
467  "monk" => $this->monk,
468  "nomos" => $this->nomos,
469  "ojo" => $this->ojo,
470  "scanoss" => $this->scanoss,
471  "reso" => $this->reso,
472  "pkgagent" => $this->pkgagent,
473  "ipra" => $this->ipra,
474  "softwareHeritage" => $this->softwareHeritage,
475  "compatibility" => $this->compatibility,
476  "kotoba" => $this->kotoba
477  ];
478  } else {
479  return [
480  "bucket" => $this->bucket,
481  "copyright_email_author" => $this->copyright,
482  "ecc" => $this->ecc,
483  "keyword" => $this->keyword,
484  "mimetype" => $this->mimetype,
485  "monk" => $this->monk,
486  "nomos" => $this->nomos,
487  "ojo" => $this->ojo,
488  "scanoss" => $this->scanoss,
489  "reso" => $this->reso,
490  "package" => $this->pkgagent,
491  "patent" => $this->ipra,
492  "heritage" => $this->softwareHeritage,
493  "compatibility" => $this->compatibility,
494  "kotoba_bulk" => $this->kotoba
495  ];
496  }
497  }
498 }
Model to hold analysis settings.
Definition: Analysis.php:21
setCompatibility($compatibility)
Definition: Analysis.php:441
getArray($version=ApiVersion::V1)
Definition: Analysis.php:458
setUsingArray($analysisArray, $version=ApiVersion::V1)
Definition: Analysis.php:155
setSoftwareHeritage($softwareHeritage)
Definition: Analysis.php:433
setBooleanProperties($array, $propertyMap)
Definition: Analysis.php:141
__construct($bucket=false, $copyright=false, $ecc=false, $keyword=false, $mimetype=false, $monk=false, $nomos=false, $ojo=false, $reso=false, $pkgagent=false, $compatibility=false, $scanoss=false, $ipra=false, $softwareHeritage=false, $kotoba=false)
Definition: Analysis.php:116
setUsingString($analysisString)
Definition: Analysis.php:184