Completed
Push — federated-circles ( ec0d47...dba84e )
by Maxence
02:42
created

BaseCircle::setType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * Circles - Bring cloud-users closer together.
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 2017
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\Circles\Model;
28
29
use OC\L10N\L10N;
30
31
class BaseCircle {
32
33
	/** @var int */
34
	private $id;
35
36
37
	/** @var L10N */
38
	protected $l10n;
39
40
	/** @var string */
41
	private $name;
42
43
	/** @var Member */
44
	private $owner;
45
46
	/** @var Member */
47
	private $user;
48
49
	/** @var string */
50
	private $description;
51
52
	/** @var int */
53
	private $type;
54
55
	/** @var string */
56
	private $creation;
57
58
	/** @var Member[] */
59
	private $members;
60
61
	/** @var FederatedLink[] */
62
	private $links;
63
64
	public function __construct($l10n, $type = -1, $name = '') {
65
		$this->l10n = $l10n;
66
67
		if ($type > -1) {
68
			$this->type = $type;
69
		}
70
		if ($name !== '') {
71
			$this->name = $name;
72
		}
73
	}
74
75
76
	public function setId($id) {
77
		$this->id = $id;
78
79
		return $this;
80
	}
81
82
	public function getId() {
83
		return $this->id;
84
	}
85
86
87
	public function setName($name) {
88
		$this->name = $name;
89
90
		return $this;
91
	}
92
93
	public function getName() {
94
		return $this->name;
95
	}
96
97
98
	public function getOwner() {
99
		return $this->owner;
100
	}
101
102
	public function setOwner($owner) {
103
		$this->owner = $owner;
104
105
		return $this;
106
	}
107
108
109
	public function getUser() {
110
		return $this->user;
111
	}
112
113
	public function setUser($user) {
114
		$this->user = $user;
115
116
		return $this;
117
	}
118
119
120
	public function setDescription($description) {
121
		$this->description = $description;
122
123
		return $this;
124
	}
125
126
	public function getDescription() {
127
		return $this->description;
128
	}
129
130
131
	public function setType($type) {
132
		$this->type = (int)$type;
133
134
		return $this;
135
	}
136
137
	public function getType() {
138
		return $this->type;
139
	}
140
141
142
	public function setCreation($creation) {
143
		$this->creation = $creation;
144
145
		return $this;
146
	}
147
148
	public function getCreation() {
149
		return $this->creation;
150
	}
151
152
153
	public function setMembers($members) {
154
		$this->members = $members;
155
156
		return $this;
157
	}
158
159
	public function getMembers() {
160
		return $this->members;
161
	}
162
163
164
	public function getRemote() {
165
		return $this->links;
166
	}
167
168
	public function addRemote($link) {
169
		array_push($this->links, $link);
170
	}
171
172
	public function getRemoteFromToken($token) {
173
		foreach ($this->links AS $link) {
174
			if ($link->getToken() === $token) {
175
				return $link;
176
			}
177
		}
178
179
		return null;
180
	}
181
182
	public function getRemoteFromAddressAndId($address, $id) {
183
		foreach ($this->links AS $link) {
184
			if ($link->getAddress() === $address && $link->getRemoteCircleId() === $id) {
185
				return $link;
186
			}
187
		}
188
189
		return null;
190
	}
191
192
}