FOSSology  4.4.0
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 $reso;
71  private $pkgagent;
76  private $compatibility;
77 
93  public function __construct($bucket = false, $copyright = false, $ecc = false, $keyword = false,
94  $mimetype = false, $monk = false, $nomos = false, $ojo = false, $reso = false, $pkgagent = false, $compatibility = false)
95  {
96  $this->bucket = $bucket;
97  $this->copyright = $copyright;
98  $this->ecc = $ecc;
99  $this->keyword = $keyword;
100  $this->mimetype = $mimetype;
101  $this->monk = $monk;
102  $this->nomos = $nomos;
103  $this->ojo = $ojo;
104  $this->reso = $reso;
105  $this->pkgagent = $pkgagent;
106  $this->compatibility = $compatibility;
107  }
108 
114  public function setUsingArray($analysisArray, $version = ApiVersion::V1)
115  {
116  if (array_key_exists("bucket", $analysisArray)) {
117  $this->bucket = filter_var($analysisArray["bucket"],
118  FILTER_VALIDATE_BOOLEAN);
119  }
120  if (array_key_exists(($version == ApiVersion::V2? "copyrightEmailAuthor" : "copyright_email_author"), $analysisArray)) {
121  $this->copyright = filter_var($analysisArray[$version == ApiVersion::V2? "copyrightEmailAuthor" : "copyright_email_author"],
122  FILTER_VALIDATE_BOOLEAN);
123  }
124  if (array_key_exists("ecc", $analysisArray)) {
125  $this->ecc = filter_var($analysisArray["ecc"], FILTER_VALIDATE_BOOLEAN);
126  }
127  if (array_key_exists("keyword", $analysisArray)) {
128  $this->keyword = filter_var($analysisArray["keyword"],
129  FILTER_VALIDATE_BOOLEAN);
130  }
131  if (array_key_exists("mime", $analysisArray)) {
132  $this->mimetype = filter_var($analysisArray["mime"],
133  FILTER_VALIDATE_BOOLEAN);
134  }
135  if (array_key_exists("monk", $analysisArray)) {
136  $this->monk = filter_var($analysisArray["monk"], FILTER_VALIDATE_BOOLEAN);
137  }
138  if (array_key_exists("nomos", $analysisArray)) {
139  $this->nomos = filter_var($analysisArray["nomos"], FILTER_VALIDATE_BOOLEAN);
140  }
141  if (array_key_exists("ojo", $analysisArray)) {
142  $this->ojo = filter_var($analysisArray["ojo"], FILTER_VALIDATE_BOOLEAN);
143  }
144  if (array_key_exists("reso", $analysisArray)) {
145  $this->reso = filter_var($analysisArray["reso"], FILTER_VALIDATE_BOOLEAN);
146  }
147  if (array_key_exists("package", $analysisArray)) {
148  $this->pkgagent = filter_var($analysisArray["package"],
149  FILTER_VALIDATE_BOOLEAN);
150  }
151  if (array_key_exists("compatibility", $analysisArray)) {
152  $this->compatibility = filter_var($analysisArray["compatibility"],
153  FILTER_VALIDATE_BOOLEAN);
154  }
155  return $this;
156  }
157 
163  public function setUsingString($analysisString)
164  {
165  if (stristr($analysisString, "bucket")) {
166  $this->bucket = true;
167  }
168  if (stristr($analysisString, "copyright")) {
169  $this->copyright = true;
170  }
171  if (stristr($analysisString, "ecc")) {
172  $this->ecc = true;
173  }
174  if (stristr($analysisString, "keyword")) {
175  $this->keyword = true;
176  }
177  if (stristr($analysisString, "mimetype")) {
178  $this->mimetype = true;
179  }
180  if (stristr($analysisString, "monk")) {
181  $this->monk = true;
182  }
183  if (stristr($analysisString, "nomos")) {
184  $this->nomos = true;
185  }
186  if (stristr($analysisString, "ojo")) {
187  $this->ojo = true;
188  }
189  if (stristr($analysisString, "reso")) {
190  $this->reso = true;
191  }
192  if (stristr($analysisString, "pkgagent")) {
193  $this->pkgagent = true;
194  }
195  if (stristr($analysisString, "compatibility")) {
196  $this->compatibility = true;
197  }
198  return $this;
199  }
200 
202 
205  public function getBucket()
206  {
207  return $this->bucket;
208  }
209 
213  public function getCopyright()
214  {
215  return $this->copyright;
216  }
217 
221  public function getEcc()
222  {
223  return $this->ecc;
224  }
225 
229  public function getKeyword()
230  {
231  return $this->keyword;
232  }
233 
237  public function getMime()
238  {
239  return $this->mimetype;
240  }
241 
245  public function getMonk()
246  {
247  return $this->monk;
248  }
249 
253  public function getNomos()
254  {
255  return $this->nomos;
256  }
257 
261  public function getOjo()
262  {
263  return $this->ojo;
264  }
265 
269  public function getReso()
270  {
271  return $this->reso;
272  }
273 
277  public function getPackage()
278  {
279  return $this->pkgagent;
280  }
281 
285  public function getCompatibility()
286  {
287  return $this->compatibility;
288  }
289 
291 
294  public function setBucket($bucket)
295  {
296  $this->bucket = filter_var($bucket, FILTER_VALIDATE_BOOLEAN);
297  }
298 
302  public function setCopyright($copyright)
303  {
304  $this->copyright = filter_var($copyright, FILTER_VALIDATE_BOOLEAN);
305  }
306 
310  public function setEcc($ecc)
311  {
312  $this->ecc = filter_var($ecc, FILTER_VALIDATE_BOOLEAN);
313  }
314 
318  public function setKeyword($keyword)
319  {
320  $this->keyword = filter_var($keyword, FILTER_VALIDATE_BOOLEAN);
321  }
322 
326  public function setMime($mime)
327  {
328  $this->mimetype = filter_var($mime, FILTER_VALIDATE_BOOLEAN);
329  }
330 
334  public function setMonk($monk)
335  {
336  $this->monk = filter_var($monk, FILTER_VALIDATE_BOOLEAN);
337  }
338 
342  public function setNomos($nomos)
343  {
344  $this->nomos = filter_var($nomos, FILTER_VALIDATE_BOOLEAN);
345  }
346 
350  public function setOjo($ojo)
351  {
352  $this->ojo = filter_var($ojo, FILTER_VALIDATE_BOOLEAN);
353  }
354 
358  public function setReso($reso)
359  {
360  $this->reso = filter_var($reso, FILTER_VALIDATE_BOOLEAN);
361  }
362 
366  public function setPackage($package)
367  {
368  $this->pkgagent = filter_var($package, FILTER_VALIDATE_BOOLEAN);
369  }
370 
375  {
376  $this->compatibility = filter_var($compatibility, FILTER_VALIDATE_BOOLEAN);
377  }
378 
383  public function getArray($version = ApiVersion::V1)
384  {
385  if ($version == ApiVersion::V2) {
386  return [
387  "bucket" => $this->bucket,
388  "copyrightEmailAuthor" => $this->copyright,
389  "ecc" => $this->ecc,
390  "keyword" => $this->keyword,
391  "mimetype" => $this->mimetype,
392  "monk" => $this->monk,
393  "nomos" => $this->nomos,
394  "ojo" => $this->ojo,
395  "reso" => $this->reso,
396  "package" => $this->pkgagent,
397  "compatibility" => $this->compatibility
398  ];
399  } else {
400  return [
401  "bucket" => $this->bucket,
402  "copyright_email_author" => $this->copyright,
403  "ecc" => $this->ecc,
404  "keyword" => $this->keyword,
405  "mimetype" => $this->mimetype,
406  "monk" => $this->monk,
407  "nomos" => $this->nomos,
408  "ojo" => $this->ojo,
409  "reso" => $this->reso,
410  "package" => $this->pkgagent,
411  "compatibility" => $this->compatibility
412  ];
413  }
414  }
415 }
Model to hold analysis settings.
Definition: Analysis.php:21
setCompatibility($compatibility)
Definition: Analysis.php:374
getArray($version=ApiVersion::V1)
Definition: Analysis.php:383
setUsingArray($analysisArray, $version=ApiVersion::V1)
Definition: Analysis.php:114
__construct($bucket=false, $copyright=false, $ecc=false, $keyword=false, $mimetype=false, $monk=false, $nomos=false, $ojo=false, $reso=false, $pkgagent=false, $compatibility=false)
Definition: Analysis.php:93
setUsingString($analysisString)
Definition: Analysis.php:163