From 85fac9b09ee806cfdec51f91ae7fb9a26b987b88 Mon Sep 17 00:00:00 2001 From: Alexis Date: Sun, 2 Apr 2023 13:42:09 +0200 Subject: [PATCH] Code smells and bugs resolve 11 --- Source/Model/ModelAdmin.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/Model/ModelAdmin.php b/Source/Model/ModelAdmin.php index 591891a..16b2d4b 100644 --- a/Source/Model/ModelAdmin.php +++ b/Source/Model/ModelAdmin.php @@ -49,7 +49,7 @@ class ModelAdmin if (validate::type($type)) { $question = new $type(0, $questionContent); $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getForm'); - if ($res->getStatusCode()!=200){ + if ($res->getStatusCode() != 200){ throw new Exception('GetForm failed'); } $form = json_decode($res->getBody()); @@ -130,7 +130,7 @@ class ModelAdmin if ($res->getStatusCode() != 200) { throw new Exception('InsertResponseInQuestion failed'); } - } catch (GuzzleException | ClientException $g){ + } catch (GuzzleException | ClientException $g) { echo "Error : " . $g->getMessage(); throw new Exception($g->getMessage(), $g->getCode(), $g); } @@ -167,7 +167,7 @@ class ModelAdmin { try { $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getForm'); - if ($res->getStatusCode()!=200){ + if ($res->getStatusCode() != 200) { throw new Exception('GetForm failed'); } $formulaire = json_decode($res->getBody()); @@ -207,7 +207,7 @@ class ModelAdmin if ($res->getStatusCode() != 200) { throw new Exception('InsertKeyword failed'); } - } catch (GuzzleException | ClientException $g){ + } catch (GuzzleException | ClientException $g) { echo "Error : " . $g->getMessage(); throw new Exception($g->getMessage(), $g->getCode(), $g); } @@ -228,7 +228,7 @@ class ModelAdmin if ($res->getStatusCode() != 200) { throw new Exception('DeleteKeyword failed'); } - } catch (GuzzleException | ClientException $g){ + } catch (GuzzleException | ClientException $g) { echo "Error : " . $g->getMessage(); throw new Exception($g->getMessage(), $g->getCode(), $g); } @@ -281,7 +281,8 @@ class ModelAdmin } $idForm = json_decode($res->getBody())[0]->id; $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions?'. - 'idForm='.$idForm); + 'idForm='.$idForm + ); if ($res->getStatusCode() != 200) { throw new Exception('GetAllQuestions failed'); } @@ -290,7 +291,7 @@ class ModelAdmin } else { return array(); } - } catch (GuzzleException | ClientException $g){ + } catch (GuzzleException | ClientException $g) { echo "Error : " . $g->getMessage(); throw new Exception($g->getMessage(), $g->getCode(), $g); } @@ -314,14 +315,15 @@ class ModelAdmin $results = []; foreach ($responsesCandidate as $response) { $res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getDetailsListResponseOfCandidate?'. - 'id='.$response->id); + 'id='.$response->id + ); if ($res->getStatusCode() != 200) { throw new Exception('GetDetailsListResponsesOfCandidate failed'); } $results[] =json_decode($res->getBody()); } return $results; - } catch (GuzzleException | ClientException $g){ + } catch (GuzzleException | ClientException $g) { echo "Error : " . $g->getMessage(); throw new Exception($g->getMessage(), $g->getCode(), $g); }