Code Duplication    Length = 14-15 lines in 3 locations

lib/Service/CardService.php 3 locations

@@ 172-186 (lines=15) @@
169
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
170
	 * @throws BadRequestException
171
	 */
172
	public function delete($id) {
173
174
		if (is_numeric($id) === false) {
175
			throw new BadRequestException('card id must be a number');
176
		}
177
178
		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
179
		if ($this->boardService->isArchived($this->cardMapper, $id)) {
180
			throw new StatusException('Operation not allowed. This board is archived.');
181
		}
182
		$card = $this->cardMapper->find($id);
183
		$card->setDeletedAt(time());
184
		$this->cardMapper->update($card);
185
		return $card;
186
	}
187
188
	/**
189
	 * @param $id
@@ 341-354 (lines=14) @@
338
	 * @throws \OCP\AppFramework\Db\
339
	 * @throws BadRequestException
340
	 */
341
	public function archive($id) {
342
343
		if (is_numeric($id) === false) {
344
			throw new BadRequestException('id must be a number');
345
		}
346
347
		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
348
		if ($this->boardService->isArchived($this->cardMapper, $id)) {
349
			throw new StatusException('Operation not allowed. This board is archived.');
350
		}
351
		$card = $this->cardMapper->find($id);
352
		$card->setArchived(true);
353
		return $this->cardMapper->update($card);
354
	}
355
356
	/**
357
	 * @param $id
@@ 365-378 (lines=14) @@
362
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
363
	 * @throws BadRequestException
364
	 */
365
	public function unarchive($id) {
366
367
		if (is_numeric($id) === false) {
368
			throw new BadRequestException('id must be a number');
369
		}
370
371
		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
372
		if ($this->boardService->isArchived($this->cardMapper, $id)) {
373
			throw new StatusException('Operation not allowed. This board is archived.');
374
		}
375
		$card = $this->cardMapper->find($id);
376
		$card->setArchived(false);
377
		return $this->cardMapper->update($card);
378
	}
379
380
	/**
381
	 * @param $cardId