FOSSology  4.7.1
Open Source License Compliance by Open Source Software
LicenseCompatibilityRule.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2026 Harshit Gandhi <gandhiharshit716@gmail.com>
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
11 namespace Fossology\UI\Api\Models;
12 
18 {
23  private $id;
28  private $firstLicenseId;
48  private $firstType;
53  private $secondType;
58  private $comment;
63  private $compatibility;
64 
79  {
80  $this->id = $id;
81  $this->firstLicenseId = $firstLicenseId;
82  $this->firstLicenseName = $firstLicenseName;
83  $this->secondLicenseId = $secondLicenseId;
84  $this->secondLicenseName = $secondLicenseName;
85  $this->firstType = $firstType;
86  $this->secondType = $secondType;
87  $this->comment = $comment;
88  $this->compatibility = $compatibility;
89  }
90 
96  public static function fromArray($row)
97  {
98  return new LicenseCompatibilityRule(
99  intval($row['lr_pk']),
100  $row['first_rf_fk'] === null ? null : intval($row['first_rf_fk']),
101  $row['first_rf_shortname'],
102  $row['second_rf_fk'] === null ? null : intval($row['second_rf_fk']),
103  $row['second_rf_shortname'],
104  $row['first_type'],
105  $row['second_type'],
106  $row['comment'],
107  $row['compatibility'] === 't'
108  );
109  }
110 
114  public function getId()
115  {
116  return $this->id;
117  }
118 
122  public function getFirstLicenseId()
123  {
124  return $this->firstLicenseId;
125  }
126 
130  public function getFirstLicenseName()
131  {
133  }
134 
138  public function getSecondLicenseId()
139  {
140  return $this->secondLicenseId;
141  }
142 
146  public function getSecondLicenseName()
147  {
149  }
150 
154  public function getFirstType()
155  {
156  return $this->firstType;
157  }
158 
162  public function getSecondType()
163  {
164  return $this->secondType;
165  }
166 
170  public function getComment()
171  {
172  return $this->comment;
173  }
174 
178  public function getCompatibility()
179  {
180  return $this->compatibility;
181  }
182 
186  public function setId($id)
187  {
188  $this->id = $id;
189  }
190 
195  {
196  $this->firstLicenseId = $firstLicenseId;
197  }
198 
203  {
204  $this->firstLicenseName = $firstLicenseName;
205  }
206 
211  {
212  $this->secondLicenseId = $secondLicenseId;
213  }
214 
219  {
220  $this->secondLicenseName = $secondLicenseName;
221  }
222 
226  public function setFirstType($firstType)
227  {
228  $this->firstType = $firstType;
229  }
230 
234  public function setSecondType($secondType)
235  {
236  $this->secondType = $secondType;
237  }
238 
242  public function setComment($comment)
243  {
244  $this->comment = $comment;
245  }
246 
251  {
252  $this->compatibility = $compatibility;
253  }
254 
260  public function getJSON($version = ApiVersion::V1)
261  {
262  return json_encode($this->getArray($version));
263  }
264 
270  public function getArray($version = ApiVersion::V1)
271  {
272  if ($version == ApiVersion::V2) {
273  return [
274  'id' => $this->getId(),
275  'firstLicenseId' => $this->getFirstLicenseId(),
276  'firstLicenseName' => $this->getFirstLicenseName(),
277  'secondLicenseId' => $this->getSecondLicenseId(),
278  'secondLicenseName' => $this->getSecondLicenseName(),
279  'firstType' => $this->getFirstType(),
280  'secondType' => $this->getSecondType(),
281  'comment' => $this->getComment(),
282  'compatibility' => $this->getCompatibility()
283  ];
284  }
285  return [
286  'id' => $this->getId(),
287  'first_license_id' => $this->getFirstLicenseId(),
288  'first_license_name' => $this->getFirstLicenseName(),
289  'second_license_id' => $this->getSecondLicenseId(),
290  'second_license_name' => $this->getSecondLicenseName(),
291  'first_type' => $this->getFirstType(),
292  'second_type' => $this->getSecondType(),
293  'comment' => $this->getComment(),
294  'compatibility' => $this->getCompatibility()
295  ];
296  }
297 }
Model to hold a single license compatibility rule.
__construct($id, $firstLicenseId, $firstLicenseName, $secondLicenseId, $secondLicenseName, $firstType, $secondType, $comment, $compatibility)