FOSSology  4.4.0
Open Source License Compliance by Open Source Software
LicenseCandidate.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2023 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
14 namespace Fossology\UI\Api\Models;
15 
17 
19 {
24  private $id;
25 
30  private $shortname;
31 
36  private $spdxid;
37 
42  private $fullname;
43 
48  private $text;
49 
54  private $group_name;
55 
60  private $group_id;
61 
73  {
74  $this->setId($id);
75  $this->setShortname($shortname);
76  $this->setSpdxId($spdxid);
77  $this->setFullname($fullname);
78  $this->setText($text);
79  $this->setGroupName($group_name);
80  $this->setGroupId($group_id);
81  }
82 
86  public function getId(): int
87  {
88  return $this->id;
89  }
90 
94  public function setId($id): void
95  {
96  $this->id = $id;
97  }
98 
102  public function getShortname(): string
103  {
104  return $this->shortname;
105  }
106 
110  public function setShortname($shortname): void
111  {
112  $this->shortname = $shortname;
113  }
114 
118  public function getSpdxid()
119  {
120  return $this->spdxid;
121  }
122 
126  public function setSpdxid($spdxid): void
127  {
128  $this->spdxid = $spdxid;
129  }
130 
134  public function getFullname()
135  {
136  return $this->fullname;
137  }
138 
142  public function setFullname($fullname): void
143  {
144  $this->fullname = $fullname;
145  }
146 
150  public function getText()
151  {
152  return $this->text;
153  }
154 
158  public function setText($text): void
159  {
160  $this->text = $text;
161  }
162 
166  public function getGroupName(): string
167  {
168  return $this->group_name;
169  }
170 
174  public function setGroupName($group_name): void
175  {
176  $this->group_name = $group_name;
177  }
178 
182  public function getGroupId(): int
183  {
184  return $this->group_id;
185  }
186 
190  public function setGroupId($group_id): void
191  {
192  $this->group_id = $group_id;
193  }
194 
195  public function getArray($apiVersion = ApiVersion::V1)
196  {
197  if ($apiVersion == ApiVersion::V2) {
198  return [
199  "id" => $this->getId(),
200  "shortname" => $this->getShortname(),
201  "spdxid" => $this->getSpdxid(),
202  "fullname" => $this->getFullname(),
203  "text" => $this->getText(),
204  "groupName" => $this->getGroupName(),
205  "groupId" => $this->getGroupId()
206  ];
207  } else {
208  return [
209  "id" => $this->getId(),
210  "shortname" => $this->getShortname(),
211  "spdxid" => $this->getSpdxid(),
212  "fullname" => $this->getFullname(),
213  "text" => $this->getText(),
214  "group_name" => $this->getGroupName(),
215  "group_id" => $this->getGroupId()
216  ];
217  }
218  }
219 
225  public static function createFromArray($licenseData)
226  {
227  return new LicenseCandidate($licenseData['rf_pk'],
228  $licenseData['rf_shortname'], $licenseData['rf_spdx_id'],
229  $licenseData['rf_fullname'], $licenseData['rf_text'],
230  $licenseData['group_name'], $licenseData['group_pk']);
231  }
232 
239  public static function convertDbArray($rows , $version = ApiVersion::V1)
240  {
241  $candidates = [];
242  if (empty($rows)) {
243  return $candidates;
244  }
245  foreach ($rows as $row) {
246  $candidates[] = self::createFromArray($row)->getArray($version);
247  }
248  return $candidates;
249  }
250 }
__construct($id, $shortname, $spdxid, $fullname, $text, $group_name, $group_id)
static convertDbArray($rows, $version=ApiVersion::V1)