Completed
Push — master ( 2813c1...14a1cb )
by Maxence
01:59
created

ProviderSubjectLink::parseLinkRequestAccepting()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 13
loc 13
rs 9.4285
cc 2
eloc 8
nc 2
nop 3
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
28
namespace OCA\Circles\Activity;
29
30
31
use OCA\Circles\Exceptions\FakeException;
32
use OCA\Circles\Model\Circle;
33
use OCA\Circles\Model\FederatedLink;
34
use OCA\Circles\Model\Member;
35
use OCP\Activity\IEvent;
36
37
class ProviderSubjectLink extends ProviderParser {
38
39
40
	/**
41
	 * @param IEvent $event
42
	 * @param Circle $circle
43
	 * @param FederatedLink $remote
44
	 *
45
	 * @throws FakeException
46
	 */
47 View Code Duplication
	public function parseLinkRequestSent(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
		if ($event->getSubject() !== 'link_request_sent') {
49
			return;
50
		}
51
52
		$this->parseCircleEvent(
53
			$event, $circle, $remote,
54
			$this->l10n->t('You sent a request to link {circle} with {remote}'),
55
			$this->l10n->t('{author} sent a request to link {circle} with {remote}')
56
		);
57
58
		throw new FakeException();
59
	}
60
61
62
	/**
63
	 * @param IEvent $event
64
	 * @param Circle $circle
65
	 * @param FederatedLink $remote
66
	 *
67
	 * @throws FakeException
68
	 */
69 View Code Duplication
	public function parseLinkRequestReceived(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
		if ($event->getSubject() !== 'link_request_received') {
71
			return;
72
		}
73
74
		$this->parseLinkEvent(
75
			$event, $circle, $remote, $this->l10n->t('{remote} requested a link with {circle}')
76
		);
77
78
		throw new FakeException();
79
	}
80
81
82
	/**
83
	 * @param IEvent $event
84
	 * @param Circle $circle
85
	 * @param FederatedLink $remote
86
	 *
87
	 * @throws FakeException
88
	 */
89 View Code Duplication
	public function parseLinkRequestRejected(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
		if ($event->getSubject() !== 'link_request_rejected') {
91
			return;
92
		}
93
94
		$this->parseLinkEvent(
95
			$event, $circle, $remote,
96
			$this->l10n->t('The request to link {circle} with {remote} has been rejected')
97
		);
98
99
		throw new FakeException();
100
	}
101
102
103
	/**
104
	 * @param IEvent $event
105
	 * @param Circle $circle
106
	 * @param FederatedLink $remote
107
	 *
108
	 * @throws FakeException
109
	 */
110 View Code Duplication
	public function parseLinkRequestCanceled(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
111
		if ($event->getSubject() !== 'link_request_canceled') {
112
			return;
113
		}
114
115
		$this->parseLinkEvent(
116
			$event, $circle, $remote,
117
			$this->l10n->t(
118
				'The request to link {remote} with {circle} has been canceled remotely'
119
			)
120
		);
121
122
		throw new FakeException();
123
	}
124
125
126
	/**
127
	 * @param IEvent $event
128
	 * @param Circle $circle
129
	 * @param FederatedLink $remote
130
	 *
131
	 * @throws FakeException
132
	 */
133 View Code Duplication
	public function parseLinkRequestAccepted(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
134
		if ($event->getSubject() !== 'link_request_accepted') {
135
			return;
136
		}
137
138
		$this->parseLinkEvent(
139
			$event, $circle, $remote,
140
			$this->l10n->t('The request to link {circle} with {remote} has been accepted')
141
		);
142
143
		throw new FakeException();
144
	}
145
146
147
	/**
148
	 * @param IEvent $event
149
	 * @param Circle $circle
150
	 * @param FederatedLink $remote
151
	 *
152
	 * @throws FakeException
153
	 */
154 View Code Duplication
	public function parseLinkRequestRemoved(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
155
		if ($event->getSubject() !== 'link_request_removed') {
156
			return;
157
		}
158
159
		$this->parseCircleEvent(
160
			$event, $circle, $remote,
161
			$this->l10n->t('You dismissed the request to link {remote} with {circle}'),
162
			$this->l10n->t('{author} dismissed the request to link {remote} with {circle}')
163
		);
164
165
		throw new FakeException();
166
	}
167
168
169
	/**
170
	 * @param IEvent $event
171
	 * @param Circle $circle
172
	 * @param FederatedLink $remote
173
	 *
174
	 * @throws FakeException
175
	 */
176 View Code Duplication
	public function parseLinkRequestCanceling(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
177
		if ($event->getSubject() !== 'link_request_canceling') {
178
			return;
179
		}
180
181
		$this->parseCircleEvent(
182
			$event, $circle, $remote,
183
			$this->l10n->t('You canceled the request to link {circle} with {remote}'),
184
			$this->l10n->t('{author} canceled the request to link {circle} with {remote}')
185
		);
186
187
		throw new FakeException();
188
	}
189
190
191
	/**
192
	 * @param IEvent $event
193
	 * @param Circle $circle
194
	 * @param FederatedLink $remote
195
	 *
196
	 * @throws FakeException
197
	 */
198 View Code Duplication
	public function parseLinkRequestAccepting(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
199
		if ($event->getSubject() !== 'link_request_accepting') {
200
			return;
201
		}
202
203
		$this->parseCircleEvent(
204
			$event, $circle, $remote,
205
			$this->l10n->t('You accepted the request to link {remote} with {circle}'),
206
			$this->l10n->t('{author} accepted the request to link {remote} with {circle}')
207
		);
208
209
		throw new FakeException();
210
	}
211
212
213
	/**
214
	 * @param IEvent $event
215
	 * @param Circle $circle
216
	 * @param FederatedLink $remote
217
	 *
218
	 * @throws FakeException
219
	 */
220 View Code Duplication
	public function parseLinkUp(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
221
		if ($event->getSubject() !== 'link_up') {
222
			return;
223
		}
224
225
		$this->parseLinkEvent(
226
			$event, $circle, $remote,
227
			$this->l10n->t('A link between {circle} and {remote} is now up and running')
228
		);
229
230
		throw new FakeException();
231
	}
232
233
234
	/**
235
	 * @param IEvent $event
236
	 * @param Circle $circle
237
	 * @param FederatedLink $remote
238
	 *
239
	 * @throws FakeException
240
	 */
241 View Code Duplication
	public function parseLinkDown(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
242
		if ($event->getSubject() !== 'link_down') {
243
			return;
244
		}
245
246
		$this->parseLinkEvent(
247
			$event, $circle, $remote,
248
			$this->l10n->t(
249
				'The link between {circle} and {remote} has been shutdown remotely'
250
			)
251
		);
252
253
		throw new FakeException();
254
	}
255
256
257
	/**
258
	 * @param IEvent $event
259
	 * @param Circle $circle
260
	 * @param FederatedLink $remote
261
	 *
262
	 * @throws FakeException
263
	 */
264 View Code Duplication
	public function parseLinkRemove(IEvent &$event, Circle $circle, FederatedLink $remote) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
265
		if ($event->getSubject() !== 'link_remove') {
266
			return;
267
		}
268
269
		$this->parseCircleEvent(
270
			$event, $circle, $remote,
271
			$this->l10n->t('You closed the link between {circle} and {remote}'),
272
			$this->l10n->t('{author} closed the link between {circle} and {remote}')
273
		);
274
275
		throw new FakeException();
276
	}
277
278
}