Passed
Pull Request — master (#878)
by Björn
07:12
created

CloudFederationProviderCalendar   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 67
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getShareType() 0 3 1
A shareReceived() 0 12 1
A notificationReceived() 0 7 1
A getSupportedShareTypes() 0 3 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2018 Bjoern Schiessle <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
22
namespace OCA\Calendar;
23
24
use OCP\Federation\Exceptions\ActionNotSupportedException;
25
use OCP\Federation\ICloudFederationProvider;
26
use OCP\Federation\ICloudFederationShare;
27
28
class CloudFederationProviderCalendar implements ICloudFederationProvider {
29
30
	/**
31
	 * get the name of the share type, handled by this provider
32
	 *
33
	 * @return string
34
	 *
35
	 * @since 14.0.0
36
	 */
37
	public function getShareType() {
38
		return 'calendar';
39
	}
40
41
	/**
42
	 * share received from another server
43
	 *
44
	 * @param ICloudFederationShare $share
45
	 * @return string provider specific unique ID of the share
46
	 *
47
	 * @throws \OCP\Federation\Exceptions\ProviderCouldNotAddShareException
48
	 *
49
	 * @since 14.0.0
50
	 */
51
	public function shareReceived(ICloudFederationShare $share) {
52
		// TODO: Implement shareReceived() method.
53
		// Here we should to the same as we do if the user add a new calendar
54
		// subscription in the user interface
55
		// We might consider to first create a notification to ask the user whether
56
		// they want to accept the share or not
57
		//
58
		// Additionally we should store it in a db table so that we have information
59
		// like the shared secret, the provider id, etc in case we exchange notifications
60
		// also in the user interface it might be nice to show some additional information like
61
		// from whom the share comes from
62
	}
63
64
	/**
65
	 * notification received from another server
66
	 *
67
	 * @param string $notificationType (e.g SHARE_ACCEPTED)
68
	 * @param string $providerId share ID
69
	 * @param array $notification provider specific notification
70
	 * @return array $data send back to sender
71
	 *
72
	 * @throws ActionNotSupportedException
73
	 *
74
	 * @since 14.0.0
75
	 */
76
	public function notificationReceived($notificationType, $providerId, array $notification) {
77
		// TODO: Implement notificationReceived() method.
78
		// let's start with a small subset of notification, I think at least a unshare
79
		// notification from the owner would be nice
80
		throw new ActionNotSupportedException($notificationType);
81
		return [];
0 ignored issues
show
Unused Code introduced by
return array(); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
82
	}
83
84
	/**
85
	 * get the supported share types, e.g. "user", "group", etc.
86
	 *
87
	 * @return array
88
	 *
89
	 * @since 14.0.0
90
	 */
91
	public function getSupportedShareTypes() {
92
		return ['user'];
93
	}
94
}
95