FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ReportImportConfiguration.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2017 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 namespace Fossology\ReportImport;
8 
10 
12 {
13  private static $keys = array(
14  'addConcludedAsDecisions', // => $createConcludedLicensesAsConclusions
15  'addLicenseInfoFromInfoInFile', // => $createLicensesInfosAsFindings
16  'addLicenseInfoFromConcluded', // => $createConcludedLicensesAsFindings
17  'addConcludedAsDecisionsOverwrite', // => $overwriteDecisions
18  'addCopyrights', // => $addCopyrightInformation
19  'addConcludedAsDecisionsTBD', // => $concludeLicenseDecisionType
20  'addNewLicensesAs', // => $createLicensesAsCandidate
21  'licenseMatch' // => $matchLicenseNameWith
22  );
23 
24  protected $createLicensesAsCandidate = true;
25  protected $createLicensesInfosAsFindings = true;
26  protected $createConcludedLicensesAsFindings = false;
27  protected $createConcludedLicensesAsConclusions = true;
28  protected $overwriteDecisions = false;
29  protected $addCopyrightInformation = false;
30  protected $concludeLicenseDecisionType = DecisionTypes::IDENTIFIED;
31  protected $matchLicenseNameWithSPDX = true;
32 
33  private function getFromArgs($args, $num, $expected="true")
34  {
35  return array_key_exists(self::$keys[$num],$args) ? $args[self::$keys[$num]] === $expected : false;
36  }
37 
38  function __construct($args)
39  {
40  $this->createConcludedLicensesAsConclusions = $this->getFromArgs($args,0);
41  $this->createLicensesInfosAsFindings = $this->getFromArgs($args,1);
42  $this->createConcludedLicensesAsFindings = $this->getFromArgs($args,2);
43  $this->overwriteDecisions = $this->getFromArgs($args,3);
44  $this->addCopyrightInformation = $this->getFromArgs($args,4);
45 
46  $addConcludedAsDecisionsTBD = $this->getFromArgs($args,5);
47  if($addConcludedAsDecisionsTBD)
48  {
49  $this->concludeLicenseDecisionType = DecisionTypes::TO_BE_DISCUSSED;
50  }
51 
52  $this->createLicensesAsCandidate = $this->getFromArgs($args, 6, "candidate");
53  $this->matchLicenseNameWithSPDX = $this->getFromArgs($args, 7, "spdxid");
54 
55  $this->echoConfiguration();
56  }
57 
58  private function var_dump($mixed = null) {
59  ob_start();
60  var_dump($mixed);
61  $dump = ob_get_contents();
62  ob_end_clean();
63  return $dump;
64  }
65 
66  public function echoConfiguration()
67  {
68  echo "INFO: \$createLicensesAsCandidate is: " .$this->var_dump($this->createLicensesAsCandidate);
69  echo "\nINFO: \$createLicensesInfosAsFindings is: " .$this->var_dump($this->createLicensesInfosAsFindings);
70  echo "\nINFO: \$createConcludedLicensesAsFindings is: " .$this->var_dump($this->createConcludedLicensesAsFindings);
71  echo "\nINFO: \$createConcludedLicensesAsConclusions is: ".$this->var_dump($this->createConcludedLicensesAsConclusions);
72  echo "\nINFO: \$overwriteDecisions is: " .$this->var_dump($this->overwriteDecisions);
73  echo "\nINFO: \$addCopyrightInformation is: " .$this->var_dump($this->addCopyrightInformation);
74  echo "\nINFO: \$concludeLicenseDecisionType is: " .$this->var_dump($this->concludeLicenseDecisionType);
75  echo "\nINFO: \$matchLicenseNameWithSPDX is: " .$this->var_dump($this->matchLicenseNameWithSPDX);
76  echo "\n";
77  }
78 
82  public function isCreateLicensesAsCandidate()
83  {
84  return $this->createLicensesAsCandidate;
85  }
86 
91  {
92  return $this->createLicensesInfosAsFindings;
93  }
94 
99  {
100  return $this->createConcludedLicensesAsFindings;
101  }
102 
107  {
108  return $this->createConcludedLicensesAsConclusions;
109  }
110 
115  {
116  return $this->concludeLicenseDecisionType;
117  }
118 
123  public function setCreateConcludedLicensesAsConclusions($createConcludedLicensesAsConclusions)
124  {
125  $this->createConcludedLicensesAsConclusions = $createConcludedLicensesAsConclusions;
126  return $this;
127  }
128 
132  public function isOverwriteDecisions()
133  {
134  return $this->overwriteDecisions;
135  }
136 
140  public function isAddCopyrightInformation()
141  {
142  return $this->addCopyrightInformation;
143  }
144 
150  {
151  return $this->matchLicenseNameWithSPDX;
152  }
153 }
setCreateConcludedLicensesAsConclusions($createConcludedLicensesAsConclusions)