/*! * GJframework * model/CustomError.class.php * v1.0.0 (03/09/2018) * * Created by Guillaume Juncker on 24/08/2018. * Copyright © Guillaume Juncker. All rights reserved. */ /** * CustomError * Classe de gestion des erreurs */ class CustomError { private $type = ""; public $message = "", $icon = ""; /*------------------------------------------------------------------------------------------------------------------------------*/ /** * __construct * Constructeur de l’objet * * @return void */ public function __construct(string $type, string $message, string $icon = NULL) { $this->type = $type; $this->message = $message; if($icon) { $this->icon = $icon;} else { switch($this->type) { case "success": $this->icon = ""; break; case "info": $this->icon = ""; break; case "warning": $this->icon = ""; break; case "danger": $this->icon = ""; break; default: break; } } } /*------------------------------------------------------------------------------------------------------------------------------*/ /** * bool * Traduit en boolean l'erreur * @return bool: TRUE en cas de succès, FALSE sinon */ public function bool() { return $this->type== "success"; } /** * toBSnotification * Met en forme l'erreur en notification * @return string: le code HTML de la notification */ public function toBSnotification() { return "
type." alert-dismissible bs-notification\" role=\"notification\" data-closedelay=\"null\"> ".$this->icon." ".$this->message."
"; } /*------------------------------------------------------------------------------------------------------------------------------*/ public function __toString() { return $this->toBSnotification(); } }