Code Duplication    Length = 17-17 lines in 2 locations

controller/playlistapicontroller.php 2 locations

@@ 196-212 (lines=17) @@
193
	 * @NoAdminRequired
194
	 * @NoCSRFRequired
195
	 */
196
	public function addTracks($id) {
197
		$newTrackIds = array();
198
		foreach (explode(',', $this->params('trackIds')) as $trackId) {
199
			$newTrackIds[] = (int) $trackId;
200
		}
201
202
		try {
203
			$playlist = $this->playlistMapper->find($id, $this->userId);
204
			$this->playlistMapper->addTracks($newTrackIds, $id);
205
			$playlist->setTrackIds($this->playlistMapper->getTracks($id));
206
207
			return $playlist->toAPI();
208
		} catch(DoesNotExistException $ex) {
209
			return new JSONResponse(array('message' => $ex->getMessage()),
210
				Http::STATUS_NOT_FOUND);
211
		}
212
	}
213
214
	/**
215
	 * removes tracks from a playlist
@@ 221-237 (lines=17) @@
218
	 * @NoAdminRequired
219
	 * @NoCSRFRequired
220
	 */
221
	public function removeTracks($id) {
222
		$trackIds = array();
223
		foreach (explode(',', $this->params('trackIds')) as $trackId) {
224
			$trackIds[] = (int) $trackId;
225
		}
226
227
		try {
228
			$playlist = $this->playlistMapper->find($id, $this->userId);
229
			$this->playlistMapper->removeTracks($id, $trackIds);
230
			$playlist->setTrackIds($this->playlistMapper->getTracks($id));
231
232
			return $playlist->toAPI();
233
		} catch(DoesNotExistException $ex) {
234
			return new JSONResponse(array('message' => $ex->getMessage()),
235
				Http::STATUS_NOT_FOUND);
236
		}
237
	}
238
}
239