Skip to content

Commit

Permalink
correct codacy issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiiii-dev committed Dec 15, 2020
1 parent faba2dc commit 7e40fc3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 32 deletions.
6 changes: 2 additions & 4 deletions src/Controller/AnswerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public function modifyAnswer(int $id)
$verifAccess = new AccessValidator();
if (!$verifAccess->isValid($idUserAnswer['idUser'] ?? null)) {
http_response_code(500);
$this->renderView('500.html.twig');
exit();
return $this->renderView('500.html.twig');
}
$this->renderView(
'modifyAnswer.html.twig',
Expand Down Expand Up @@ -74,8 +73,7 @@ public function deleteAnswer(int $id)
$verifAccess = new AccessValidator();
if (!$verifAccess->isValid($answerInfo['idUser'] ?? null)) {
http_response_code(500);
$this->renderView('500.html.twig');
exit();
return $this->renderView('500.html.twig');
}
$session = new MessageFlash();
$session->setFlashMessage('Votre réponse a bien été supprimée !', 'success');
Expand Down
9 changes: 3 additions & 6 deletions src/Controller/BloggerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public function show(int $id)

if (!$bloggerInfo) {
http_response_code(404);
$this->renderView('404.html.twig');
exit();
return $this->renderView('404.html.twig');
}

$cookie = $_COOKIE['auth'] ?? null;
Expand Down Expand Up @@ -50,8 +49,7 @@ public function modifyProfil(int $id)

if (!$verifAccess->isValid($bloggerInfo['idUser'])) {
http_response_code(500);
$this->renderView('500.html.twig');
exit();
return $this->renderView('500.html.twig');
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
Expand All @@ -66,8 +64,7 @@ public function modifyProfil(int $id)
$checkForm = new FormValidator();

if (!$checkForm->checkModifProfile($_POST)) {
header('Location: /Blog/modify-profil/' . $id);
exit();
return header('Location: /Blog/modify-profil/' . $id);
}
$session->setFlashMessage('Votre profil a bien été modifié !', 'success');
$bloggerRepo->modifyProfil($id, $blogger);
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function sendNewPassword()
if (!$userRepo->getUserByEmail($email)) {
$session = new MessageFlash();
$session->setFlashMessage('Le mail saisi n\'existe pas ! ', 'danger');
header("Location: /Blog/sign-in");
exit();
return header("Location: /Blog/sign-in");
}

$randomPassword = new RandomPassword();
Expand Down
21 changes: 7 additions & 14 deletions src/Controller/PostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public function show(int $id)
$cookie = explode('-----', $cookie);
if (!$postInfo) {
http_response_code(404);
$this->renderView('404.html.twig');
exit();
return $this->renderView('404.html.twig');
}
$userName = $post->getUserForAPost($id);
$answerRepo = new AnswerRepository();
Expand Down Expand Up @@ -57,8 +56,7 @@ public function showAllPosts($page)
$hasPost = false;
} else if ($paginationConf['overPage']) {
http_response_code(404);
$this->renderView('404.html.twig');
exit();
return $this->renderView('404.html.twig');
}

$this->renderView(
Expand All @@ -81,8 +79,7 @@ public function createPost()
$verifAccess = new AccessValidator();
if ($verifAccess->isValid($_SESSION['id'] ?? $cookie[0]) === false) {
http_response_code(500);
$this->renderView(ERR_500);
exit();
return $this->renderView(ERR_500);
}

$session = new MessageFlash();
Expand All @@ -109,8 +106,7 @@ public function createPost()
$checkPost = new FormValidator();

if (!$checkPost->checkPost($post)) {
header('Location: /Blog/create-post');
exit();
return header('Location: /Blog/create-post');
}

$session = new MessageFlash();
Expand All @@ -134,8 +130,7 @@ public function modifyPost(int $id)

if (!$verifAccess->isValid($postInfo['idUser'] ?? null)) {
http_response_code(500);
$this->renderView(ERR_500);
exit();
return $this->renderView(ERR_500);
}
$this->renderView(
'modifyPost.html.twig',
Expand Down Expand Up @@ -166,8 +161,7 @@ public function modifyPost(int $id)
$checkPost = new FormValidator();

if (!$checkPost->checkPost($post)) {
header('Location: /Blog/modify-post/' . $id);
exit();
return header('Location: /Blog/modify-post/' . $id);
}
$session = new MessageFlash();
$session->setFlashMessage('Votre post a bien été modifié !', 'alert alert-success');
Expand All @@ -184,8 +178,7 @@ public function deletePost(int $id)

if (!$verifAccess->isValid($postInfo['idUser'] ?? null)) {
http_response_code(500);
$this->renderView(ERR_500);
exit();
return $this->renderView(ERR_500);
}
$session = new MessageFlash();
$session->setFlashMessage('Votre post a bien été supprimé !', 'alert alert-success');
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/SigninController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public function signIn()
$userManager = new UserManager();
$checkSignIn = new FormValidator();
if (!$checkSignIn->checkSignIn($user)) {
header('Location: /Blog/sign-in');
exit();
return header('Location: /Blog/sign-in');
}
$session = new MessageFlash();
$session->setFlashMessage('Vous êtes bien connecté !', 'success');
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/SignupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public function signUp()
$checkSignIn = new FormValidator();

if (!$checkSignIn->checkSignUp($user)) {
header('Location: /Blog/sign-up');
exit();
return header('Location: /Blog/sign-up');
}
$session = new MessageFlash();
$session->setFlashMessage('Votre compte a bien été créé ! Vous pouvez maintenant vous connecter', 'success');
Expand Down
3 changes: 1 addition & 2 deletions src/Services/AccessValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public function isValidAdmin(string $type = null): bool
{
if ($type != "Admin") {
http_response_code(500);
$this->renderView('500.html.twig');
exit();
return $this->renderView('500.html.twig');
}
return true;
}
Expand Down

0 comments on commit 7e40fc3

Please sign in to comment.