Code Duplication    Length = 14-15 lines in 2 locations

micro/controllers/rest/RestController.php 2 locations

@@ 211-225 (lines=15) @@
208
	 * @param array $keyValues
209
	 * @authorization
210
	 */
211
	public function update(...$keyValues){
212
		$instance=DAO::getOne($this->model, $keyValues);
213
		if(isset($instance)){
214
			$this->_setValuesToObject($instance,RequestUtils::getInput());
215
			$result=DAO::update($instance);
216
			if($result){
217
				echo $this->responseFormatter->format(["status"=>"updated","data"=>$instance->_rest]);
218
			}else{
219
				throw new \Exception("Unable to update the instance");
220
			}
221
		}else{
222
			$this->_setResponseCode(404);
223
			echo $this->responseFormatter->format(["message"=>"No result found","keyValues"=>$keyValues]);
224
		}
225
	}
226
227
	/**
228
	 * Insert a new instance of $model
@@ 256-269 (lines=14) @@
253
	 * @route("methods"=>["delete"])
254
	 * @authorization
255
	 */
256
	public function delete(...$keyValues){
257
		$instance=DAO::getOne($this->model, $keyValues);
258
		if(isset($instance)){
259
			$result=DAO::remove($instance);
260
			if($result){
261
				echo $this->responseFormatter->format(["status"=>"deleted","data"=>$instance->_rest]);
262
			}else{
263
				throw new \Exception("Unable to delete the instance");
264
			}
265
		}else{
266
			$this->_setResponseCode(404);
267
			echo $this->responseFormatter->format(["message"=>"No result found","keyValues"=>$keyValues]);
268
		}
269
	}
270
}
271