From 537d588726f0ddc1a3a0327156912a0ec4089abb Mon Sep 17 00:00:00 2001 From: Donquixote Date: Sat, 29 Oct 2016 18:00:01 +0800 Subject: [PATCH] refactoring code to reduce cyclomatic complexit Signed-off-by: Roeland Jago Douma --- lib/public/AppFramework/Controller.php | 8 +++----- lib/public/AppFramework/OCSController.php | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/public/AppFramework/Controller.php b/lib/public/AppFramework/Controller.php index f730799bec..9fb7646e1a 100644 --- a/lib/public/AppFramework/Controller.php +++ b/lib/public/AppFramework/Controller.php @@ -92,9 +92,8 @@ abstract class Controller { } $response->setHeaders(array_merge($dataHeaders, $headers)); return $response; - } else { - return new JSONResponse($data); } + return new JSONResponse($data); } ); } @@ -153,10 +152,9 @@ abstract class Controller { return $responder($response); - } else { - throw new \DomainException('No responder registered for format ' . - $format . '!'); } + throw new \DomainException('No responder registered for format '. + $format . '!'); } diff --git a/lib/public/AppFramework/OCSController.php b/lib/public/AppFramework/OCSController.php index 5f18ba0807..9b3b12e2b9 100644 --- a/lib/public/AppFramework/OCSController.php +++ b/lib/public/AppFramework/OCSController.php @@ -106,12 +106,9 @@ abstract class OCSController extends ApiController { */ private function buildOCSResponse($format, DataResponse $data) { if ($this->ocsVersion === 1) { - $response = new \OC\AppFramework\OCS\V1Response($data, $format); - } else { - $response = new \OC\AppFramework\OCS\V2Response($data, $format); + return new \OC\AppFramework\OCS\V1Response($data, $format); } - - return $response; + return new \OC\AppFramework\OCS\V2Response($data, $format); } }