FOSSology  4.5.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;
92 
110  public function __construct($bucket = false, $copyright = false, $ecc = false, $keyword = false,
111  $mimetype = false, $monk = false, $nomos = false, $ojo = false, $reso = false, $pkgagent = false, $compatibility = false, $scanoss = false, $ipra = false, $softwareHeritage = false)
112  {
113  $this->bucket = $bucket;
114  $this->copyright = $copyright;
115  $this->ecc = $ecc;
116  $this->keyword = $keyword;
117  $this->mimetype = $mimetype;
118  $this->monk = $monk;
119  $this->nomos = $nomos;
120  $this->ojo = $ojo;
121  $this->scanoss = $scanoss;
122  $this->reso = $reso;
123  $this->pkgagent = $pkgagent;
124  $this->ipra = $ipra;
125  $this->softwareHeritage = $softwareHeritage;
126  $this->compatibility = $compatibility;
127  }
128 
134  private function setBooleanProperties($array, $propertyMap)
135  {
136  foreach ($propertyMap as $key => $property) {
137  if (array_key_exists($key, $array)) {
138  $this->$property = filter_var($array[$key], FILTER_VALIDATE_BOOLEAN);
139  }
140  }
141  }
142 
148  public function setUsingArray($analysisArray, $version = ApiVersion::V1)
149  {
150  $propertyMap = [
151  'bucket' => 'bucket',
152  ($version == ApiVersion::V2 ? 'copyrightEmailAuthor' : 'copyright_email_author') => 'copyright',
153  'ecc' => 'ecc',
154  'keyword' => 'keyword',
155  'mime' => 'mimetype',
156  'monk' => 'monk',
157  'nomos' => 'nomos',
158  'ojo' => 'ojo',
159  'scanoss' => 'scanoss',
160  'reso' => 'reso',
161  ($version == ApiVersion::V2 ? "pkgagent" : "package") => 'pkgagent',
162  ($version == ApiVersion::V2 ? 'ipra' : 'patent') => 'ipra',
163  ($version == ApiVersion::V2 ? 'softwareHeritage' : "heritage") => 'softwareHeritage',
164  'compatibility' => 'compatibility'
165  ];
166 
167  $this->setBooleanProperties($analysisArray, $propertyMap);
168  return $this;
169  }
170 
176  public function setUsingString($analysisString)
177  {
178  $propertyMap = [
179  'bucket' => 'bucket',
180  'copyright' => 'copyright',
181  'ecc' => 'ecc',
182  'keyword' => 'keyword',
183  'mimetype' => 'mimetype',
184  'monk' => 'monk',
185  'nomos' => 'nomos',
186  'ojo' => 'ojo',
187  'scanoss' => 'scanoss',
188  'reso' => 'reso',
189  'pkgagent' => 'pkgagent',
190  'ipra' => 'ipra',
191  'softwareHeritage' => 'softwareHeritage',
192  'compatibility' => 'compatibility'
193  ];
194 
195  foreach ($propertyMap as $key => $property) {
196  if (stristr($analysisString, $key)) {
197  $this->$property = true;
198  }
199  }
200  return $this;
201  }
202 
204 
207  public function getBucket()
208  {
209  return $this->bucket;
210  }
211 
215  public function getCopyright()
216  {
217  return $this->copyright;
218  }
219 
223  public function getEcc()
224  {
225  return $this->ecc;
226  }
227 
231  public function getKeyword()
232  {
233  return $this->keyword;
234  }
235 
239  public function getMime()
240  {
241  return $this->mimetype;
242  }
243 
247  public function getMonk()
248  {
249  return $this->monk;
250  }
251 
255  public function getNomos()
256  {
257  return $this->nomos;
258  }
259 
263  public function getOjo()
264  {
265  return $this->ojo;
266  }
267 
271  public function getScanoss()
272  {
273  return $this->scanoss;
274  }
275 
279  public function getReso()
280  {
281  return $this->reso;
282  }
283 
287  public function getPkgagent()
288  {
289  return $this->pkgagent;
290  }
291 
295  public function getIpra()
296  {
297  return $this->ipra;
298  }
299 
303  public function getSoftwareHeritage()
304  {
306  }
307 
311  public function getCompatibility()
312  {
313  return $this->compatibility;
314  }
315 
317 
320  public function setBucket($bucket)
321  {
322  $this->bucket = filter_var($bucket, FILTER_VALIDATE_BOOLEAN);
323  }
324 
328  public function setCopyright($copyright)
329  {
330  $this->copyright = filter_var($copyright, FILTER_VALIDATE_BOOLEAN);
331  }
332 
336  public function setEcc($ecc)
337  {
338  $this->ecc = filter_var($ecc, FILTER_VALIDATE_BOOLEAN);
339  }
340 
344  public function setKeyword($keyword)
345  {
346  $this->keyword = filter_var($keyword, FILTER_VALIDATE_BOOLEAN);
347  }
348 
352  public function setMime($mime)
353  {
354  $this->mimetype = filter_var($mime, FILTER_VALIDATE_BOOLEAN);
355  }
356 
360  public function setMonk($monk)
361  {
362  $this->monk = filter_var($monk, FILTER_VALIDATE_BOOLEAN);
363  }
364 
368  public function setNomos($nomos)
369  {
370  $this->nomos = filter_var($nomos, FILTER_VALIDATE_BOOLEAN);
371  }
372 
376  public function setOjo($ojo)
377  {
378  $this->ojo = filter_var($ojo, FILTER_VALIDATE_BOOLEAN);
379  }
380 
384  public function setScanoss($scanoss)
385  {
386  $this->scanoss = filter_var($scanoss, FILTER_VALIDATE_BOOLEAN);
387  }
388 
392  public function setReso($reso)
393  {
394  $this->reso = filter_var($reso, FILTER_VALIDATE_BOOLEAN);
395  }
396 
400  public function setPkgagent($pkgagent)
401  {
402  $this->pkgagent = filter_var($pkgagent, FILTER_VALIDATE_BOOLEAN);
403  }
404 
408  public function setIpra($ipra)
409  {
410  $this->ipra = filter_var($ipra, FILTER_VALIDATE_BOOLEAN);
411  }
412 
417  {
418  $this->softwareHeritage = filter_var($softwareHeritage, FILTER_VALIDATE_BOOLEAN);
419  }
420 
425  {
426  $this->compatibility = filter_var($compatibility, FILTER_VALIDATE_BOOLEAN);
427  }
428 
433  public function getArray($version = ApiVersion::V1)
434  {
435  if ($version == ApiVersion::V2) {
436  return [
437  "bucket" => $this->bucket,
438  "copyrightEmailAuthor" => $this->copyright,
439  "ecc" => $this->ecc,
440  "keyword" => $this->keyword,
441  "mimetype" => $this->mimetype,
442  "monk" => $this->monk,
443  "nomos" => $this->nomos,
444  "ojo" => $this->ojo,
445  "scanoss" => $this->scanoss,
446  "reso" => $this->reso,
447  "pkgagent" => $this->pkgagent,
448  "ipra" => $this->ipra,
449  "softwareHeritage" => $this->softwareHeritage,
450  "compatibility" => $this->compatibility
451  ];
452  } else {
453  return [
454  "bucket" => $this->bucket,
455  "copyright_email_author" => $this->copyright,
456  "ecc" => $this->ecc,
457  "keyword" => $this->keyword,
458  "mimetype" => $this->mimetype,
459  "monk" => $this->monk,
460  "nomos" => $this->nomos,
461  "ojo" => $this->ojo,
462  "scanoss" => $this->scanoss,
463  "reso" => $this->reso,
464  "package" => $this->pkgagent,
465  "patent" => $this->ipra,
466  "heritage" => $this->softwareHeritage,
467  "compatibility" => $this->compatibility
468  ];
469  }
470  }
471 }
Model to hold analysis settings.
Definition: Analysis.php:21
setCompatibility($compatibility)
Definition: Analysis.php:424
getArray($version=ApiVersion::V1)
Definition: Analysis.php:433
setUsingArray($analysisArray, $version=ApiVersion::V1)
Definition: Analysis.php:148
setSoftwareHeritage($softwareHeritage)
Definition: Analysis.php:416
setBooleanProperties($array, $propertyMap)
Definition: Analysis.php:134
__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)
Definition: Analysis.php:110
setUsingString($analysisString)
Definition: Analysis.php:176