Code Duplication    Length = 20-20 lines in 2 locations

apps/dav/lib/CardDAV/AddressBook.php 1 location

@@ 142-161 (lines=20) @@
139
		return parent::getOwner();
140
	}
141
142
	function delete() {
143
		if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
144
			$principal = 'principal:' . parent::getOwner();
145
			$shares = $this->getShares();
146
			$shares = array_filter($shares, function($share) use ($principal){
147
				return $share['href'] === $principal;
148
			});
149
			if (empty($shares)) {
150
				throw new Forbidden();
151
			}
152
153
			/** @var CardDavBackend $cardDavBackend */
154
			$cardDavBackend = $this->carddavBackend;
155
			$cardDavBackend->updateShares($this, [], [
156
				'href' => $principal
157
			]);
158
			return;
159
		}
160
		parent::delete();
161
	}
162
163
	function propPatch(PropPatch $propPatch) {
164
		if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {

apps/dav/lib/CalDAV/Calendar.php 1 location

@@ 151-170 (lines=20) @@
148
		return parent::getOwner();
149
	}
150
151
	function delete() {
152
		if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
153
			$principal = 'principal:' . parent::getOwner();
154
			$shares = $this->getShares();
155
			$shares = array_filter($shares, function($share) use ($principal){
156
				return $share['href'] === $principal;
157
			});
158
			if (empty($shares)) {
159
				throw new Forbidden();
160
			}
161
162
			/** @var CalDavBackend $calDavBackend */
163
			$calDavBackend = $this->caldavBackend;
164
			$calDavBackend->updateShares($this, [], [
165
				'href' => $principal
166
			]);
167
			return;
168
		}
169
		parent::delete();
170
	}
171
172
	function propPatch(PropPatch $propPatch) {
173
		$mutations = $propPatch->getMutations();