Code Duplication    Length = 9-10 lines in 3 locations

controller/playlistapicontroller.php 3 locations

@@ 152-160 (lines=9) @@
149
	 * @NoAdminRequired
150
	 * @NoCSRFRequired
151
	 */
152
	public function update($id) {
153
		try {
154
			$playlist = $this->playlistBusinessLayer->rename($this->params('name'), $id, $this->userId);
155
			return $playlist->toAPI();
156
		} catch(DoesNotExistException $ex) {
157
			return new JSONResponse(array('message' => $ex->getMessage()),
158
				Http::STATUS_NOT_FOUND);
159
		}
160
	}
161
162
	/**
163
	 * add tracks to a playlist
@@ 169-178 (lines=10) @@
166
	 * @NoAdminRequired
167
	 * @NoCSRFRequired
168
	 */
169
	public function addTracks($id) {
170
		try {
171
			$playlist = $this->playlistBusinessLayer->addTracks(
172
					$this->paramArray('trackIds'), $id, $this->userId);
173
			return $playlist->toAPI();
174
		} catch(DoesNotExistException $ex) {
175
			return new JSONResponse(array('message' => $ex->getMessage()),
176
				Http::STATUS_NOT_FOUND);
177
		}
178
	}
179
180
	/**
181
	 * removes tracks from a playlist
@@ 187-196 (lines=10) @@
184
	 * @NoAdminRequired
185
	 * @NoCSRFRequired
186
	 */
187
	public function removeTracks($id) {
188
		try {
189
			$playlist = $this->playlistBusinessLayer->removeTracks(
190
					$this->paramArray('indices'), $id, $this->userId);
191
			return $playlist->toAPI();
192
		} catch(DoesNotExistException $ex) {
193
			return new JSONResponse(array('message' => $ex->getMessage()),
194
				Http::STATUS_NOT_FOUND);
195
		}
196
	}
197
198
	private function paramArray($name) {
199
		$array = array();