FOSSology  4.4.0
Open Source License Compliance by Open Source Software
UserGroupMember.php
Go to the documentation of this file.
1 <?php
2 /*
3  * SPDX-FileCopyrightText: © 2022 Samuel Dushimimana <dushsam100@gmail.com>
4  *
5  * SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 namespace Fossology\UI\Api\Models;
14 
16 {
17 
21  private $user;
22 
26  private $group_perm;
27 
34  public function __construct($user, $group_perm)
35  {
36  $this->user = $user;
37  $this->group_perm = intval($group_perm);
38  }
39 
41 
45  public function setUser($user)
46  {
47  $this->user = $user;
48  }
49 
53  public function setGroupPerm($group_perm)
54  {
55  $this->group_perm = intval($group_perm);
56  }
57 
58 
60 
64  public function getUser()
65  {
66  return $this->user;
67  }
68 
72  public function getGroupPerm()
73  {
74  return $this->group_perm;
75  }
76 
80  public function getJSON()
81  {
82  return json_encode($this->getArray());
83  }
84 
90  public function getArray($version=ApiVersion::V1)
91  {
92  if ($version==ApiVersion::V2) {
93  return [
94  'user' => $this->user->getArray($version),
95  'groupPerm' => intval($this->group_perm)
96  ];
97  } else {
98  return [
99  'user' => $this->user->getArray($version),
100  'group_perm' => intval($this->group_perm)
101  ];
102  }
103  }
104 }