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 {
22  private $id;
23 
28  private $shortname;
29 
34  private $spdxid;
35 
40  private $fullname;
41 
46  private $text;
47 
52  private $group_name;
53 
58  private $group_id;
59 
71  {
72  $this->setId($id);
73  $this->setShortname($shortname);
74  $this->setSpdxId($spdxid);
75  $this->setFullname($fullname);
76  $this->setText($text);
77  $this->setGroupName($group_name);
78  $this->setGroupId($group_id);
79  }
80 
84  public function getId(): int
85  {
86  return $this->id;
87  }
88 
92  public function setId($id): void
93  {
94  $this->id = $id;
95  }
96 
100  public function getShortname(): string
101  {
102  return $this->shortname;
103  }
104 
108  public function setShortname($shortname): void
109  {
110  $this->shortname = $shortname;
111  }
112 
116  public function getSpdxid()
117  {
118  return $this->spdxid;
119  }
120 
124  public function setSpdxid($spdxid): void
125  {
126  $this->spdxid = $spdxid;
127  }
128 
132  public function getFullname()
133  {
134  return $this->fullname;
135  }
136 
140  public function setFullname($fullname): void
141  {
142  $this->fullname = $fullname;
143  }
144 
148  public function getText()
149  {
150  return $this->text;
151  }
152 
156  public function setText($text): void
157  {
158  $this->text = $text;
159  }
160 
164  public function getGroupName(): string
165  {
166  return $this->group_name;
167  }
168 
172  public function setGroupName($group_name): void
173  {
174  $this->group_name = $group_name;
175  }
176 
180  public function getGroupId(): int
181  {
182  return $this->group_id;
183  }
184 
188  public function setGroupId($group_id): void
189  {
190  $this->group_id = $group_id;
191  }
192 
193  public function getArray()
194  {
195  return [
196  "id" => $this->getId(),
197  "shortname" => $this->getShortname(),
198  "spdxid" => $this->getSpdxid(),
199  "fullname" => $this->getFullname(),
200  "text" => $this->getText(),
201  "group_name" => $this->getGroupName(),
202  "group_id" => $this->getGroupId()
203  ];
204  }
205 
211  public static function createFromArray($licenseData)
212  {
213  return new LicenseCandidate($licenseData['rf_pk'],
214  $licenseData['rf_shortname'], $licenseData['rf_spdx_id'],
215  $licenseData['rf_fullname'], $licenseData['rf_text'],
216  $licenseData['group_name'], $licenseData['group_pk']);
217  }
218 
225  public static function convertDbArray($rows)
226  {
227  $candidates = [];
228  if (empty($rows)) {
229  return $candidates;
230  }
231  foreach ($rows as $row) {
232  $candidates[] = self::createFromArray($row)->getArray();
233  }
234  return $candidates;
235  }
236 }
__construct($id, $shortname, $spdxid, $fullname, $text, $group_name, $group_id)