From 0cd93fd938a59c696190db0af7dc21d83250a0b8 Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 7 Feb 2023 14:12:17 +0100 Subject: [PATCH] SonarQube code smells resolve #21 --- Source/API/script/Gateway/GatewayForm.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/API/script/Gateway/GatewayForm.php b/Source/API/script/Gateway/GatewayForm.php index 6d14881..520ea68 100644 --- a/Source/API/script/Gateway/GatewayForm.php +++ b/Source/API/script/Gateway/GatewayForm.php @@ -18,11 +18,11 @@ class GatewayForm public function insertForm(Form $form): void { - if(empty($this->getForm())) { - $query = "INSERT INTO Form(title, description) VALUES(:title, :description)"; + if (empty($this->getForm())) { + $query = "INSERT INTO Form(title, description) VALUES(:title, :desc)"; $this->connection->executeQuery($query, array( ':title' => array($form->getTitle(), PDO::PARAM_STR), - ':description' => array($form->getDescription(), PDO::PARAM_STR) + ':desc' => array($form->getDescription(), PDO::PARAM_STR) )); } } @@ -45,7 +45,10 @@ class GatewayForm public function assignKeywordToQuestion(string $keyword, string $response, int $idQuestion): void { - $query = "SELECT pr.id FROM Propose p, PossibleResponse pr WHERE p.question = :id AND p.possibleResponse = pr.id AND pr.content = :response"; + $query = "SELECT pr.id + FROM Propose p, PossibleResponse pr + WHERE p.question = :id AND p.possibleResponse = pr.id + AND pr.content = :response"; $this->connection->executeQuery($query, array( ':id' => array($idQuestion, PDO::PARAM_INT), ':response' => array($response, PDO::PARAM_STR) @@ -62,7 +65,9 @@ class GatewayForm public function deleteKeywordFromQuestion(string $keyword, string $response, Question $question): void { - $query = "SELECT pr.id FROM Propose p, PossibleResponse r WHERE p.question = :id AND p.possibleResponse = pr.id AND pr.content = :response"; + $query = "SELECT pr.id FROM Propose p, PossibleResponse r + WHERE p.question = :id AND p.possibleResponse = pr.id + AND pr.content = :response"; $this->connection->executeQuery($query, array( ':id' => array($question->getId(), PDO::PARAM_INT), ':response' => array($response, PDO::PARAM_STR) @@ -97,9 +102,9 @@ class GatewayForm public function deleteDescriptionToForm(Form $form): void { - $query = "UPDATE Form SET title = :title WHERE description = :description"; + $query = "UPDATE Form SET title = :title WHERE description = :descript"; $this->connection->executeQuery($query, array( - ':description' => array('', PDO::PARAM_STR), + ':descript' => array('', PDO::PARAM_STR), ':id' => array($form->getId(), PDO::PARAM_INT) )); }