Passed
Pull Request — master (#1128)
by René
08:09 queued 03:52
created

UserGroupClass::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <[email protected]>
4
 *
5
 * @author René Gieling <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Polls\Model;
25
26
class UserGroupClass implements \JsonSerializable {
27
	public const TYPE = 'generic';
28
	public const TYPE_PUBLIC = 'public';
29
	public const TYPE_EXTERNAL = 'external';
30
31
	/** @var IL10N */
0 ignored issues
show
Bug introduced by
The type OCA\Polls\Model\IL10N was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
	private $l10n;
33
34
	/** @var string */
35
	protected $id;
36
37
	/** @var string */
38
	protected $type;
39
40
	/** @var string */
41
	protected $displayName = '';
42
43
	/** @var string */
44
	protected $description = '';
45
46
	/** @var string */
47
	protected $emailAddress = '';
48
49
	/** @var string */
50
	protected $language = '';
51
52
	/** @var string */
53
	protected $organisation = '';
54
55
	/** @var string */
56
	protected $icon = '';
57
58
	/** @var string */
59
	protected $isNoUser = '';
60
61
	/** @var string */
62
	protected $categories = '';
63
64
	/**
65
	 * User constructor.
66
	 * @param $id
67
	 * @param $displayName
68
	 */
69
	public function __construct(
70
		$id,
71
		$type,
72
		$displayName = '',
73
		$emailAddress = '',
74
		$language = ''
75
	) {
76
		$this->id = $id;
77
		$this->type = $type;
78
		$this->displayName = $displayName;
79
		$this->emailAddress = $emailAddress;
80
		$this->language = $language;
81
		$this->icon = 'icon-share';
82
		$this->l10n = \OC::$server->getL10N('polls');
83
		$this->isNoUser = true;
0 ignored issues
show
Documentation Bug introduced by
The property $isNoUser was declared of type string, but true is of type true. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
84
	}
85
86
	/**
87
	 * getId
88
	 * @NoAdminRequired
89
	 * @return String
90
	 */
91
	public function getId() {
92
		return $this->id;
93
	}
94
95
	/**
96
	 * getUser
97
	 * @NoAdminRequired
98
	 * @return String
99
	 */
100
	public function getUser() {
101
		return $this->id;
102
	}
103
104
	/**
105
	 * getType
106
	 * @NoAdminRequired
107
	 * @return String
108
	 */
109
	public function getType() {
110
		return $this->type;
111
	}
112
113
	/**
114
	 * getLanguage
115
	 * @NoAdminRequired
116
	 * @return String
117
	 */
118
	public function getLanguage() {
119
		return $this->language;
120
	}
121
122
	/**
123
	 * getDisplayName
124
	 * @NoAdminRequired
125
	 * @return String
126
	 */
127
	public function getDisplayName() {
128
		if ($this->displayName) {
129
			return $this->displayName;
130
		}
131
		return $this->id;
132
	}
133
134
	/**
135
	 * getDescription
136
	 * @NoAdminRequired
137
	 * @return String
138
	 */
139
	public function getDescription() {
140
		return $this->description;
141
	}
142
143
	/**
144
	 * getIcon
145
	 * @NoAdminRequired
146
	 * @return String
147
	 */
148
	public function getIcon() {
149
		return $this->icon;
150
	}
151
152
	/**
153
	 * getEmailAddress
154
	 * @NoAdminRequired
155
	 * @return String
156
	 */
157
	public function getEmailAddress() {
158
		return $this->emailAddress;
159
	}
160
161
	/**
162
	 * getOrganisation
163
	 * @NoAdminRequired
164
	 * @return String
165
	 */
166
	public function getOrganisation() {
167
		return $this->organisation;
168
	}
169
170
	/**
171
	 * getCategories
172
	 * @NoAdminRequired
173
	 * @return Array
174
	 */
175
	public function getCategories() {
176
		return $this->categories;
177
	}
178
179
	/**
180
	 * getOrganisation
181
	 * @NoAdminRequired
182
	 * @return String
183
	 */
184
	public function getIsNoUser() {
185
		return $this->isNoUser;
186
	}
187
188
	/**
189
	 * setType
190
	 * @NoAdminRequired
191
	 * @param string $type
192
	 * @return String
193
	 */
194
	public function setType($type) {
195
		$this->type = $type;
196
		return $this->type;
197
	}
198
199
	/**
200
	 * setDisplayName
201
	 * @NoAdminRequired
202
	 * @param string $displayName
203
	 * @return String
204
	 */
205
	public function setDisplayName($displayName) {
206
		$this->displayName = $displayName;
207
		return $this->displayName;
208
	}
209
210
	/**
211
	 * setDescription
212
	 * @NoAdminRequired
213
	 * @param string $description
214
	 * @return String
215
	 */
216
	public function setDescription($description) {
217
		$this->description = $description;
218
		return $this->description;
219
	}
220
221
	/**
222
	 * setEmailAddress
223
	 * @NoAdminRequired
224
	 * @param string $emailAddress
225
	 * @return String
226
	 */
227
	public function setEmailAddress($emailAddress) {
228
		$this->emailAddress = $emailAddress;
229
		return $this->emailAddress;
230
	}
231
232
	/**
233
	 * setLanguage
234
	 * @NoAdminRequired
235
	 * @param string $language
236
	 * @return String
237
	 */
238
	public function setLanguage($language) {
239
		$this->language = $language;
240
		return $this->language;
241
	}
242
243
	/**
244
	 * setOrganisation
245
	 * @NoAdminRequired
246
	 * @param string $organisation
247
	 * @return String
248
	 */
249
	public function setOrganisation($organisation) {
250
		$this->organisation = $organisation;
251
		return $this->organisation;
252
	}
253
254
	/**
255
	 * search
256
	 * @NoAdminRequired
257
	 * @return Array
258
	 */
259
	public static function search() {
260
		return [];
261
	}
262
263
	/**
264
	 * @return array
265
	 */
266
	public function jsonSerialize(): array {
267
		return	[
268
			'id'        	=> $this->getId(),
269
			'user'          => $this->getId(),
270
			'type'       	=> $this->getType(),
271
			'displayName'	=> $this->getDisplayName(),
272
			'organisation'	=> $this->getOrganisation(),
273
			'emailAddress'	=> $this->getEmailAddress(),
274
			'language'		=> $this->getLanguage(),
275
			'desc' 			=> $this->getDescription(),
276
			'icon'			=> $this->getIcon(),
277
			'categories'	=> $this->getCategories(),
278
			'isNoUser'		=> $this->getIsNoUser(),
279
		];
280
	}
281
}
282