Passed
Push — master ( 25fe32...0fb74a )
by Morris
13:02 queued 10s
created

CachedSubscriptionObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A put() 0 2 1
A get() 0 8 2
A delete() 0 2 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright 2018 Georg Ehrke <[email protected]>
5
 *
6
 * @author Georg Ehrke <[email protected]>
7
 *
8
 * @license GNU AGPL version 3 or any later version
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License as
12
 * published by the Free Software Foundation, either version 3 of the
13
 * License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 *
23
 */
24
namespace OCA\DAV\CalDAV;
25
26
use Sabre\DAV\Exception\MethodNotAllowed;
27
28
/**
29
 * Class CachedSubscriptionObject
30
 *
31
 * @package OCA\DAV\CalDAV
32
 * @property CalDavBackend $caldavBackend
33
 */
34
class CachedSubscriptionObject extends \Sabre\CalDAV\CalendarObject {
35
36
	/**
37
	 * @inheritdoc
38
	 */
39
	public function get() {
40
		// Pre-populating the 'calendardata' is optional, if we don't have it
41
		// already we fetch it from the backend.
42
		if (!isset($this->objectData['calendardata'])) {
43
			$this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
44
		}
45
46
		return $this->objectData['calendardata'];
47
	}
48
49
	/**
50
	 * @param resource|string $calendarData
51
	 * @return string|void
52
	 * @throws MethodNotAllowed
53
	 */
54
	public function put($calendarData) {
55
		throw new MethodNotAllowed('Creating objects in a cached subscription is not allowed');
56
	}
57
58
	/**
59
	 * @throws MethodNotAllowed
60
	 */
61
	public function delete() {
62
		throw new MethodNotAllowed('Deleting objects in a cached subscription is not allowed');
63
	}
64
}
65