FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ReportImportConfiguration.php
1 <?php
2 /*
3  * Copyright (C) 2017, Siemens AG
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 namespace Fossology\ReportImport;
19 
21 
23 {
24  private static $keys = array(
25  'addConcludedAsDecisions', // => $createConcludedLicensesAsConclusions
26  'addLicenseInfoFromInfoInFile', // => $createLicensesInfosAsFindings
27  'addLicenseInfoFromConcluded', // => $createConcludedLicensesAsFindings
28  'addConcludedAsDecisionsOverwrite', // => $overwriteDecisions
29  'addCopyrights', // => $addCopyrightInformation
30  'addConcludedAsDecisionsTBD', // => $concludeLicenseDecisionType
31  'addNewLicensesAs' // => $createLicensesAsCandidate
32  );
33 
34  protected $createLicensesAsCandidate = true;
35  protected $createLicensesInfosAsFindings = true;
36  protected $createConcludedLicensesAsFindings = false;
37  protected $createConcludedLicensesAsConclusions = true;
38  protected $overwriteDecisions = false;
39  protected $addCopyrightInformation = false;
40  protected $concludeLicenseDecisionType = DecisionTypes::IDENTIFIED;
41 
42  private function getFromArgs($args, $num, $expected="true")
43  {
44  return array_key_exists(self::$keys[$num],$args) ? $args[self::$keys[$num]] === $expected : false;
45  }
46 
47  function __construct($args)
48  {
49  $this->createConcludedLicensesAsConclusions = $this->getFromArgs($args,0);
50  $this->createLicensesInfosAsFindings = $this->getFromArgs($args,1);
51  $this->createConcludedLicensesAsFindings = $this->getFromArgs($args,2);
52  $this->overwriteDecisions = $this->getFromArgs($args,3);
53  $this->addCopyrightInformation = $this->getFromArgs($args,4);
54 
55  $addConcludedAsDecisionsTBD = $this->getFromArgs($args,5);
56  if($addConcludedAsDecisionsTBD)
57  {
58  $this->concludeLicenseDecisionType = DecisionTypes::TO_BE_DISCUSSED;
59  }
60 
61  $this->createLicensesAsCandidate = $this->getFromArgs($args, 6, "candidate");
62 
63  $this->echoConfiguration();
64  }
65 
66  private function var_dump($mixed = null) {
67  ob_start();
68  var_dump($mixed);
69  $dump = ob_get_contents();
70  ob_end_clean();
71  return $dump;
72  }
73 
74  public function echoConfiguration()
75  {
76  echo "INFO: \$createLicensesAsCandidate is: " .$this->var_dump($this->createLicensesAsCandidate);
77  echo "\nINFO: \$createLicensesInfosAsFindings is: " .$this->var_dump($this->createLicensesInfosAsFindings);
78  echo "\nINFO: \$createConcludedLicensesAsFindings is: " .$this->var_dump($this->createConcludedLicensesAsFindings);
79  echo "\nINFO: \$createConcludedLicensesAsConclusions is: ".$this->var_dump($this->createConcludedLicensesAsConclusions);
80  echo "\nINFO: \$overwriteDecisions is: " .$this->var_dump($this->overwriteDecisions);
81  echo "\nINFO: \$addCopyrightInformation is: " .$this->var_dump($this->addCopyrightInformation);
82  echo "\nINFO: \$concludeLicenseDecisionType is: " .$this->var_dump($this->concludeLicenseDecisionType);
83  echo "\n";
84  }
85 
89  public function isCreateLicensesAsCandidate()
90  {
91  return $this->createLicensesAsCandidate;
92  }
93 
98  {
99  return $this->createLicensesInfosAsFindings;
100  }
101 
106  {
107  return $this->createConcludedLicensesAsFindings;
108  }
109 
114  {
115  return $this->createConcludedLicensesAsConclusions;
116  }
117 
122  {
123  return $this->concludeLicenseDecisionType;
124  }
125 
130  public function setCreateConcludedLicensesAsConclusions($createConcludedLicensesAsConclusions)
131  {
132  $this->createConcludedLicensesAsConclusions = $createConcludedLicensesAsConclusions;
133  return $this;
134  }
135 
139  public function isOverwriteDecisions()
140  {
141  return $this->overwriteDecisions;
142  }
143 
147  public function isAddCopyrightInformation()
148  {
149  return $this->addCopyrightInformation;
150  }
151 }
setCreateConcludedLicensesAsConclusions($createConcludedLicensesAsConclusions)