Completed
Push — federated-circles ( 08a2a5...ec0d47 )
by Maxence
08:34
created

FederatedLink::getLocalAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
class FederatedLink implements \JsonSerializable {
30
31
32
	/** @var string */
33
	private $token;
34
35
	/** @var string */
36
	private $address;
37
38
	/** @var string */
39
	private $localAddress;
40
41
	/** @var int */
42
	private $status;
43
44
	/** @var int */
45
	private $creation;
46
47
	/** @var int */
48
	private $remoteCircleId;
49
50
	/** @var string */
51
	private $remoteCircleName;
52
53
	/** @var string */
54
	private $localCircleName;
55
56
57
	public function __construct() {
58
	}
59
60
61
	/**
62
	 * @param $token
63
	 *
64
	 * @return $this
65
	 */
66
	public function setToken(string $token) {
67
		$this->token = $token;
68
69
		return $this;
70
	}
71
72
	/**
73
	 * @return string
74
	 */
75
	public function getToken() {
76
		return $this->token;
77
	}
78
79
	/**
80
	 * @return string
81
	 */
82
	public function generateToken() {
83
		$token = '';
84
		for ($i = 0; $i <= 5; $i++) {
85
			$token .= uniqid('', true);
86
		}
87
88
		$this->setToken($token);
89
90
		return $token;
91
	}
92
93
94
	/**
95
	 * @param string $address
96
	 *
97
	 * @return FederatedLink
98
	 */
99
	public function setAddress(string $address) {
100
		$this->address = $address;
101
102
		return $this;
103
	}
104
105
	/**
106
	 * @return string
107
	 */
108
	public function getAddress() {
109
		return $this->address;
110
	}
111
112
113
	/**
114
	 * @param string $address
115
	 *
116
	 * @return FederatedLink
117
	 */
118
	public function setLocalAddress(string $address) {
119
		$this->localAddress = $address;
120
121
		return $this;
122
	}
123
124
	/**
125
	 * @return string
126
	 */
127
	public function getLocalAddress() {
128
		return $this->localAddress;
129
	}
130
131
132
	/**
133
	 * @param int $circleId
134
	 *
135
	 * @return FederatedLink
136
	 */
137
	public function setRemoteCircleId(int $circleId) {
138
		$this->remoteCircleId = $circleId;
139
140
		return $this;
141
	}
142
143
	/**
144
	 * @return int
145
	 */
146
	public function getRemoteCircleId() {
147
		return $this->remoteCircleId;
148
	}
149
150
151
	/**
152
	 * @param string $circleName
153
	 *
154
	 * @return FederatedLink
155
	 */
156
	public function setRemoteCircleName(string $circleName) {
157
		$this->remoteCircleName = $circleName;
158
159
		return $this;
160
	}
161
162
	/**
163
	 * @return string
164
	 */
165
	public function getRemoteCircleName() {
166
		return $this->remoteCircleName;
167
	}
168
169
170
	/**
171
	 * @param string $circleName
172
	 *
173
	 * @return FederatedLink
174
	 */
175
	public function setLocalCircleName(string $circleName) {
176
		$this->localCircleName = $circleName;
177
178
		return $this;
179
	}
180
181
	/**
182
	 * @return string
183
	 */
184
	public function getLocalCircleName() {
185
		return $this->localCircleName;
186
	}
187
188
189
	/**
190
	 * @param int $status
191
	 *
192
	 * @return FederatedLink
193
	 */
194
	public function setStatus(int $status) {
195
		$this->status = $status;
196
197
		return $this;
198
	}
199
200
	/**
201
	 * @return int
202
	 */
203
	public function getStatus() {
204
		return $this->status;
205
	}
206
207
208
	/**
209
	 * @param int $creation
210
	 *
211
	 * @return FederatedLink
212
	 */
213
	public function setCreation($creation) {
214
		if ($creation === null) {
215
			return $this;
216
		}
217
218
		$this->creation = $creation;
219
220
		return $this;
221
	}
222
223
	/**
224
	 * @return int
225
	 */
226
	public function getCreation() {
227
		return $this->creation;
228
	}
229
230
231
	public function jsonSerialize() {
232
		return array(
233
			'token'    => $this->getToken(),
234
			'address'  => $this->getAddress(),
235
			'status'   => $this->getStatus(),
236
			'creation' => $this->getCreation()
237
		);
238
	}
239
240
	public static function fromJSON($json) {
0 ignored issues
show
Unused Code introduced by
The parameter $json is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
241
	}
242
243
}