Code Duplication    Length = 14-15 lines in 2 locations

Ubiquity/controllers/rest/RestController.php 2 locations

@@ 226-240 (lines=15) @@
223
	 * @param array $keyValues
224
	 * @authorization
225
	 */
226
	public function update(...$keyValues){
227
		$instance=DAO::getOne($this->model, $keyValues);
228
		if(isset($instance)){
229
			$this->_setValuesToObject($instance,URequest::getInput());
230
			$result=DAO::update($instance);
231
			if($result){
232
				echo $this->responseFormatter->format(["status"=>"updated","data"=>$this->responseFormatter->cleanRestObject($instance)]);
233
			}else{
234
				throw new \Exception("Unable to update the instance");
235
			}
236
		}else{
237
			$this->_setResponseCode(404);
238
			echo $this->responseFormatter->format(["message"=>"No result found","keyValues"=>$keyValues]);
239
		}
240
	}
241
242
	/**
243
	 * Insert a new instance of $model
@@ 271-284 (lines=14) @@
268
	 * @route("methods"=>["delete"])
269
	 * @authorization
270
	 */
271
	public function delete(...$keyValues){
272
		$instance=DAO::getOne($this->model, $keyValues);
273
		if(isset($instance)){
274
			$result=DAO::remove($instance);
275
			if($result){
276
				echo $this->responseFormatter->format(["status"=>"deleted","data"=>$this->responseFormatter->cleanRestObject($instance)]);
277
			}else{
278
				throw new \Exception("Unable to delete the instance");
279
			}
280
		}else{
281
			$this->_setResponseCode(404);
282
			echo $this->responseFormatter->format(["message"=>"No result found","keyValues"=>$keyValues]);
283
		}
284
	}
285
}
286