Passed
Pull Request — master (#1545)
by Julius
03:01
created

CalendarObject   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 124
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 16
lcom 2
cbo 2
dl 0
loc 124
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getOwner() 0 3 1
A getGroup() 0 3 1
A getACL() 0 3 1
A setACL() 0 3 1
A getSupportedPrivilegeSet() 0 3 1
A put() 0 3 1
A get() 0 5 2
A getContentType() 0 3 1
A getETag() 0 3 1
A getSize() 0 3 1
A delete() 0 3 1
A getName() 0 3 1
A setName() 0 3 1
A getLastModified() 0 3 1
1
<?php
2
/**
3
 * @copyright 2020, Georg Ehrke <[email protected]>
4
 *
5
 * @author Georg Ehrke <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
namespace OCA\Deck\DAV;
24
25
use OCA\Deck\Db\Card;
26
use OCA\Deck\Service\CardService;
27
use Sabre\VObject\Component\VCalendar;
28
29
class CalendarObject implements \Sabre\CalDAV\ICalendarObject, \Sabre\DAVACL\IACL {
30
31
	/** @var Calendar */
32
	private $calendar;
33
34
	/** @var string */
35
	private $name;
36
	/**
37
	 * @var Card
38
	 */
39
	private $card;
40
41
	/**
42
	 * CalendarObject constructor.
43
	 *
44
	 * @param Calendar $calendar
45
	 * @param string $name
46
	 */
47
	public function __construct(Calendar $calendar, string $name, Card $card = null) {
48
		$this->calendar = $calendar;
49
		$this->name = $name;
50
		$this->card = $card;
51
	}
52
53
	/**
54
	 * @inheritDoc
55
	 */
56
	function getOwner() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
		return null;
58
	}
59
60
	/**
61
	 * @inheritDoc
62
	 */
63
	function getGroup() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
64
		return null;
65
	}
66
67
	/**
68
	 * @inheritDoc
69
	 */
70
	function getACL() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
71
		return $this->calendar->getACL();
72
	}
73
74
	/**
75
	 * @inheritDoc
76
	 */
77
	function setACL(array $acl) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
78
		throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node');
79
	}
80
81
	/**
82
	 * @inheritDoc
83
	 */
84
	function getSupportedPrivilegeSet() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
85
		return null;
86
	}
87
88
	/**
89
	 * @inheritDoc
90
	 */
91
	function put($data) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
92
		throw new \Sabre\DAV\Exception\Forbidden('This calendar-object is read-only');
93
	}
94
95
	/**
96
	 * @inheritDoc
97
	 */
98
	function get() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
99
		if ($this->card) {
100
			return $this->card->getCalendarObject()->serialize();
101
		}
102
	}
103
104
	/**
105
	 * @inheritDoc
106
	 */
107
	function getContentType() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
108
		return 'text/calendar; charset=utf-8';
109
	}
110
111
	/**
112
	 * @inheritDoc
113
	 */
114
	function getETag() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
115
		return '"' . md5($this->get()) . '"';
116
	}
117
118
	/**
119
	 * @inheritDoc
120
	 */
121
	function getSize() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
122
		return strlen($this->get());
123
	}
124
125
	/**
126
	 * @inheritDoc
127
	 */
128
	function delete() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
129
		throw new \Sabre\DAV\Exception\Forbidden('This calendar-object is read-only');
130
	}
131
132
	/**
133
	 * @inheritDoc
134
	 */
135
	function getName() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
136
		return $this->name;
137
	}
138
139
	/**
140
	 * @inheritDoc
141
	 */
142
	function setName($name) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
143
		throw new \Sabre\DAV\Exception\Forbidden('This calendar-object is read-only');
144
	}
145
146
	/**
147
	 * @inheritDoc
148
	 */
149
	function getLastModified() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
150
		return $this->card->getLastModified();
151
	}
152
}
153