FOSSology  4.4.0
Open Source License Compliance by Open Source Software
OneShot.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2024 Divij Sharma <divijs75@gmail.com>
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 namespace Fossology\UI\Api\Models;
14 
16 
17 class OneShot
18 {
22  private $data;
23 
27  private $highlights;
28 
35  public function __construct($data, $highlights)
36  {
37  $this->data = $data;
38  $this->highlights = $highlights;
39  }
40 
42 
46  public function setData($data)
47  {
48  $this->data = $data;
49  }
50 
54  public function setHighlights($highlights)
55  {
56  $this->highlights = $highlights;
57  }
58 
60 
64  public function getData()
65  {
66  return $this->data;
67  }
68 
72  public function getHighlights()
73  {
74  return $this->highlights;
75  }
76 
80  public function getJSON()
81  {
82  return json_encode($this->getArray());
83  }
84 
88  public function getHighlightsArray()
89  {
90  $highlightsArray = array_map(function($highlight) {
91  return $highlight->getArray();
92  }, $this->highlights);
93  return $highlightsArray;
94  }
95 
101  public function getArray($dataType = 'licenses')
102  {
103  return [
104  $dataType => $this->data,
105  'highlights' => $this->getHighlightsArray()
106  ];
107  }
108 }
getArray($dataType='licenses')
Definition: OneShot.php:101
__construct($data, $highlights)
Definition: OneShot.php:35