Completed
Push — master ( d25a96...09c66c )
by Lukas
16:05 queued 44s
created

PublicCalendar::getMultipleChildren()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 9

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 1
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017, Georg Ehrke
4
 *
5
 * @author Georg Ehrke <[email protected]>
6
 *
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
namespace OCA\DAV\CalDAV;
23
24
use Sabre\DAV\Exception\NotFound;
25
26
class PublicCalendar extends Calendar {
27
28
	/**
29
	 * @param string $name
30
	 * @throws NotFound
31
	 * @return PublicCalendarObject
32
	 */
33 View Code Duplication
	public function getChild($name) {
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...
34
		$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
35
36
		if (!$obj) {
37
			throw new NotFound('Calendar object not found');
38
		}
39
		if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
40
			throw new NotFound('Calendar object not found');
41
		}
42
		$obj['acl'] = $this->getChildACL();
43
44
		return new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
45
	}
46
47
	/**
48
	 * @return PublicCalendarObject[]
49
	 */
50 View Code Duplication
	public function getChildren() {
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...
51
		$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
52
		$children = [];
53
		foreach ($objs as $obj) {
54
			if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
55
				continue;
56
			}
57
			$obj['acl'] = $this->getChildACL();
58
			$children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
59
		}
60
		return $children;
61
	}
62
63
	/**
64
	 * @param string[] $paths
65
	 * @return PublicCalendarObject[]
66
	 */
67 View Code Duplication
	public function getMultipleChildren(array $paths) {
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...
68
		$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
69
		$children = [];
70
		foreach ($objs as $obj) {
71
			if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
72
				continue;
73
			}
74
			$obj['acl'] = $this->getChildACL();
75
			$children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
76
		}
77
		return $children;
78
	}
79
80
	/**
81
	 * public calendars are always shared
82
	 * @return bool
83
	 */
84
	protected function isShared() {
85
		return true;
86
	}
87
}