FOSSology  4.4.0
Open Source License Compliance by Open Source Software
DefinitionSummary.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2020 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
8 
14 {
20 
25  private $url;
26 
31  private $release;
32 
37  private $files;
38 
43  private $attribution;
44 
50 
55  private $score;
56 
61  public function __construct($result)
62  {
63  $this->attribution = "";
64  $this->declaredLicense = "NOASSERTION";
65  $this->discoveredLicenses = "";
66  $this->files = 0;
67  $this->release = "";
68  $this->url = "";
69  $this->score = 0;
70 
71  if (array_key_exists('licensed', $result)) {
72  $licensed = $result["licensed"];
73  if (array_key_exists("declared", $licensed)) {
74  $this->declaredLicense = $licensed["declared"];
75  }
76  if (array_key_exists("facets", $licensed) &&
77  array_key_exists("core", $licensed["facets"])) {
78  $core = $licensed["facets"]["core"];
79  if (array_key_exists("files", $core)) {
80  $this->files = intval($core["files"]);
81  }
82  if (array_key_exists("attribution", $core) &&
83  array_key_exists("parties", $core["attribution"])) {
84  $this->attribution = substr(
85  implode(", ", $core['attribution']['parties']), 0, 100);
86  }
87  if (array_key_exists("discovered", $core) &&
88  array_key_exists("expressions", $core["discovered"])) {
89  $this->discoveredLicenses = substr(
90  implode(", ", $core['discovered']['expressions']), 0, 100);
91  }
92  }
93  }
94 
95  if (array_key_exists("described", $result)) {
96  $described = $result["described"];
97  if (array_key_exists("sourceLocation", $described) &&
98  array_key_exists("url", $described["sourceLocation"])) {
99  $this->url = $described["sourceLocation"]["url"];
100  } else if (array_key_exists("urls", $described) &&
101  array_key_exists("version", $described["urls"])) {
102  $this->url = $described["urls"]["version"];
103  }
104  if (array_key_exists("releaseDate", $described)) {
105  $this->release = $described["releaseDate"];
106  }
107  }
108 
109  if (array_key_exists("scores", $result) &&
110  array_key_exists("effective", $result["scores"])) {
111  $this->score = $result["scores"]["effective"];
112  }
113  }
114 
118  public function getDeclaredLicense()
119  {
120  return $this->declaredLicense;
121  }
122 
126  public function getUrl()
127  {
128  return $this->url;
129  }
130 
134  public function getRelease()
135  {
136  return $this->release;
137  }
138 
142  public function getFiles()
143  {
144  return $this->files;
145  }
146 
150  public function getAttribution()
151  {
152  return $this->attribution;
153  }
154 
158  public function getDiscoveredLicenses()
159  {
161  }
162 
166  public function getScore()
167  {
168  return $this->score;
169  }
170 }