Code Duplication    Length = 16-17 lines in 2 locations

controller/apikeycontroller.php 1 location

@@ 39-54 (lines=16) @@
36
	 * @param $id int
37
	 * @return JSONResponse
38
	 */
39
	public function updateKey($key, $id) {
40
41
		$apikey = new ApiKey();
42
		$apikey->setId($id);
43
		$apikey->setApiKey($key);
44
45
		/* Only save apiKey if it exists in db */
46
		try {
47
			$this->apiKeyMapper->find($id);
48
			return new JSONResponse($this->apiKeyMapper->update($apikey));
49
		} catch(\OCP\AppFramework\Db\DoesNotExistException $e) {
50
			return new JSONResponse([
51
				'error' => $e->getMessage()
52
			]);
53
		}
54
	}
55
56
	/**
57
	 * @NoAdminRequired

controller/favoritecontroller.php 1 location

@@ 39-55 (lines=17) @@
36
	 * @param $id int
37
	 * @return JSONResponse
38
	 */
39
	public function updateFavorite($name, $id) {
40
41
		$favorite = new Favorite();
42
		$favorite->setId($id);
43
		$favorite->setName($name);
44
		$favorite->setTimestamp(time());
45
46
		/* Only save favorite if it exists in db */
47
		try {
48
			$this->favoriteMapper->find($id);
49
			return new JSONResponse($this->favoriteMapper->update($favorite));
50
		} catch(\OCP\AppFramework\Db\DoesNotExistException $e) {
51
			return new JSONResponse([
52
				'error' => $e->getMessage()
53
			]);
54
		}
55
	}
56
57
	/**
58
	 * @NoAdminRequired