Completed
Push — master ( 0c68cd...766ef1 )
by Maxence
02:02
created

FileShares::getUsers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Files_FullTextSearch - Index the content of your files
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2018
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
namespace OCA\Files_FullTextSearch\Model;
28
29
class FileShares implements \JsonSerializable {
30
31
	/** @var array */
32
	private $users = [];
33
34
	/** @var array */
35
	private $groups = [];
36
37
	/** @var array */
38
	private $circles = [];
39
40
	/** @var array */
41
	private $links = [];
42
43
44
	/**
45
	 * FileShares constructor.
46
	 *
47
	 * @param FileShares $currentShares
0 ignored issues
show
Documentation introduced by
Should the type for parameter $currentShares not be null|FileShares?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
48
	 */
49
	public function __construct(FileShares $currentShares = null) {
50
		if ($currentShares === null) {
51
			return;
52
		}
53
54
		$this->setUsers($currentShares->getUsers());
55
		$this->setGroups($currentShares->getGroups());
56
		$this->setCircles($currentShares->getCircles());
57
		$this->setLinks($currentShares->getLinks());
58
	}
59
60
61
	/**
62
	 * @return array
63
	 */
64
	public function getUsers() {
65
		return $this->users;
66
	}
67
68
	/**
69
	 * @param array $users
70
	 *
71
	 * @return $this
72
	 */
73
	public function setUsers($users) {
74
		$this->users = $users;
75
76
		return $this;
77
	}
78
79
	/**
80
	 * @param string $user
81
	 *
82
	 * @return $this
83
	 */
84
	public function addUser($user) {
85
		if (!in_array($user, $this->users)) {
86
			array_push($this->users, $user);
87
		}
88
89
		return $this;
90
	}
91
92
93
	/**
94
	 * @return array
95
	 */
96
	public function getGroups() {
97
		return $this->groups;
98
	}
99
100
	/**
101
	 * @param array $groups
102
	 *
103
	 * @return $this
104
	 */
105
	public function setGroups($groups) {
106
		$this->groups = $groups;
107
108
		return $this;
109
	}
110
111
	/**
112
	 * @param string $group
113
	 *
114
	 * @return $this
115
	 */
116
	public function addGroup($group) {
117
		if (!in_array($group, $this->groups)) {
118
			array_push($this->groups, $group);
119
		}
120
121
		return $this;
122
	}
123
124
	/**
125
	 * @return array
126
	 */
127
	public function getCircles() {
128
		return $this->circles;
129
	}
130
131
	/**
132
	 * @param array $circles
133
	 *
134
	 * @return $this
135
	 */
136
	public function setCircles($circles) {
137
		$this->circles = $circles;
138
139
		return $this;
140
	}
141
142
	/**
143
	 * @param string $circle
144
	 *
145
	 * @return $this
146
	 */
147
	public function addCircle($circle) {
148
		if (!in_array($circle, $this->circles)) {
149
			array_push($this->circles, $circle);
150
		}
151
152
		return $this;
153
	}
154
155
156
	/**
157
	 * @return array
158
	 */
159
	public function getLinks() {
160
		return $this->links;
161
	}
162
163
	/**
164
	 * @param array $links
165
	 *
166
	 * @return $this
167
	 */
168
	public function setLinks($links) {
169
		$this->links = $links;
170
171
		return $this;
172
	}
173
174
	/**
175
	 * @param string $link
176
	 *
177
	 * @return FileShares
178
	 */
179
	public function addLink($link) {
180
		if (!in_array($link, $this->links)) {
181
			array_push($this->links, $link);
182
		}
183
184
		return $this;
185
	}
186
187
188
	public function jsonSerialize() {
189
		return [
190
			'users'   => $this->getUsers(),
191
			'groups'  => $this->getGroups(),
192
			'circles' => $this->getCircles(),
193
			'links'   => $this->getLinks()
194
		];
195
	}
196
197
}