Code smells and bugs resolve 10
continuous-integration/drone/push Build is passing Details

master
Alexis 2 years ago
parent 071b3f4fd4
commit 966e961c1b

@ -20,7 +20,8 @@ class ModelCandidate
private Client $client;
public function __construct(){
public function __construct()
{
$this->client = new Client(['headers' => ['Content-Type' => 'application/json'], 'verify' => false]);
}
@ -43,8 +44,8 @@ class ModelCandidate
$category = [];
$questionsId = [];
foreach ($answersAndCategories as $answerAndCategory) {
$exploded = explode("||",$answerAndCategory);
if( count($exploded) == 3 ){
$exploded = explode("||", $answerAndCategory);
if (count($exploded) == 3) {
$questionsId[] = Clean::int($exploded[0]);
$answer[] = Clean::simpleString($exploded[1]);
$categs = Clean::simpleString($exploded[2]);
@ -60,7 +61,7 @@ class ModelCandidate
}
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');
}
$form = json_decode($res->getBody());
@ -72,12 +73,12 @@ class ModelCandidate
'category='.$cate.'&'.
'titleForm='.$title
);
if ($res->getStatusCode()!=200){
if ($res->getStatusCode() != 200) {
throw new Exception('InsertListResponsesOfCandidate failed');
}
}catch (GuzzleException | ClientException $g){
echo "Error : ".$g->getMessage();
throw new Exception($g->getMessage(),$g->getCode(),$g);
} catch (GuzzleException | ClientException $g) {
echo "Error : " . $g->getMessage();
throw new Exception($g->getMessage(), $g->getCode(), $g);
}
}
@ -94,7 +95,7 @@ class ModelCandidate
{
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');
}
$form = json_decode($res->getBody());
@ -107,19 +108,19 @@ class ModelCandidate
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getAllQuestions?'.
'idForm='.$form[0]->id
);
if ($res->getStatusCode()!=200){
if ($res->getStatusCode() != 200) {
throw new Exception('GetAllQuestion failed');
}
$questionsTab = json_decode($res->getBody());
}catch (GuzzleException | ClientException $g){
echo "Error : ".$g->getMessage();
throw new Exception($g->getMessage(),$g->getCode(),$g);
} catch (GuzzleException | ClientException $g){
echo "Error : " . $g->getMessage();
throw new Exception($g->getMessage(), $g->getCode(), $g);
}
$questions = Factory::getBuiltObjects($questionsTab, "Question");
$nbQuestions = count($questions);
$time = round(($nbQuestions * 20)/60);
$time = round(($nbQuestions * 20) / 60);
$html = "<div class='container mt-5'>
<div class='row d-flex justify-content-center align-items-center'>
@ -132,11 +133,11 @@ class ModelCandidate
$html.= "</div>";
foreach ($questions as $question) {
$html.= $question->printStrategy()."\n";
$html .= $question->printStrategy() . "\n";
}
if (count($questions) > 0) {
$html.= "<div class='thanks-message text-center' id='text-message'> <img src='https://i.imgur.com/O18mJ1K.png' alt='text-message' width='100' class='mb-4' >
$html .= "<div class='thanks-message text-center' id='text-message'> <img src='https://i.imgur.com/O18mJ1K.png' alt='text-message' width='100' class='mb-4' >
<h3>Souhaitez-vous envoyer vos réponses ?</span>
<input type='hidden' name='data_ids' value=''>
<input type='submit' value='Envoyer' id='button'>\n
@ -152,7 +153,7 @@ class ModelCandidate
</div>
</div>";
} else {
$html.= "\t\t</form>\n
$html .= "\t\t</form>\n
\t</div>\n";
}
@ -165,7 +166,7 @@ class ModelCandidate
* @throws Exception
*/
public function login() :void {
global $rep,$views,$sel;
global $rep, $views, $sel;
$password = Clean::simpleString($_REQUEST['password']);
$identifiant = Clean::simpleString($_REQUEST['login']);
try {
@ -173,7 +174,7 @@ class ModelCandidate
$res = $this->client->request('GET', 'https://codefirst.iut.uca.fr/containers/Temoignages-deploy_api_form/getPasswordWithLogin?'.
'login='.$identifiant
);
if ($res->getStatusCode()!=200){
if ($res->getStatusCode() != 200) {
throw new Exception('GetPasswordWithLogin failed');
}
$passwordbdd = json_decode($res->getBody());
@ -188,9 +189,9 @@ class ModelCandidate
} else {
throw new InvalidLoginOrPasswordException();
}
}catch (GuzzleException | ClientException $g){
echo "Error : ".$g->getMessage();
throw new Exception($g->getMessage(),$g->getCode(),$g);
} catch (GuzzleException | ClientException $g) {
echo "Error : " . $g->getMessage();
throw new Exception($g->getMessage(), $g->getCode(), $g);
}
}
}

Loading…
Cancel
Save