Création de quelques classes en vue d'une restructuration du code
This commit is contained in:
parent
d2a0d0fbec
commit
9c62d676e9
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
|
||||
class Role extends SplEnum
|
||||
{
|
||||
const __default = self::PARTICIPANT;
|
||||
|
||||
const PARTICIPANT = 0;
|
||||
const ENCADRANT = 1;
|
||||
const ORGANIZER = 2;
|
||||
const ADMIN = 3;
|
||||
|
||||
public function getName() {
|
||||
switch ($this) {
|
||||
case self::ENCADRANT:
|
||||
return "Encadrant";
|
||||
case self::ORGANIZER:
|
||||
return "Organisateur";
|
||||
case self::ADMIN:
|
||||
return "Administrateur";
|
||||
default:
|
||||
return "Participant";
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromName($name) {
|
||||
switch ($name) {
|
||||
case "ENCADRANT":
|
||||
return self::ENCADRANT;
|
||||
case "ORGANIZER":
|
||||
return self::ORGANIZER;
|
||||
case "ADMIN":
|
||||
return self::ADMIN;
|
||||
default:
|
||||
return self::PARTICIPANT;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
class Team
|
||||
{
|
||||
private $id;
|
||||
private $name;
|
||||
private $trigram;
|
||||
private $tournament;
|
||||
private $encadrants;
|
||||
private $participants;
|
||||
private $inscription_date;
|
||||
private $validation_status;
|
||||
private $final_selection;
|
||||
private $access_code;
|
||||
private $year;
|
||||
|
||||
public function __construct($id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT * FROM `teams` WHERE `id` = ?;");
|
||||
$req->execute([htmlspecialchars($id)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
throw new InvalidArgumentException("L'équipe spécifiée n'existe pas.");
|
||||
|
||||
$this->id = $id;
|
||||
$this->name = $data["name"];
|
||||
$this->trigram = $data["trigram"];
|
||||
$this->tournament = $data["tournament"];
|
||||
$this->encadrants = [$data["encadrant_1"], $data["encadrant_2"]];
|
||||
$this->participants = [$data["participant_1"], $data["participant_2"], $data["participant_3"], $data["participant_4"], $data["participant_5"], $data["participant_6"]];
|
||||
$this->inscription_date = $data["inscription_date"];
|
||||
$this->validation_status = ValidationStatus::fromName($data["validation_status"]);
|
||||
$this->final_selection = $data["final_selection"] == true;
|
||||
$this->access_code = $data["access_code"];
|
||||
$this->year = $data["year"];
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
global $DB;
|
||||
$this->name = $name;
|
||||
$DB->prepare("UPDATE `teams` SET `name` = ? WHERE `id` = ?;")->execute([$name, $this->id]);
|
||||
}
|
||||
|
||||
public function getTrigram()
|
||||
{
|
||||
return $this->trigram;
|
||||
}
|
||||
|
||||
public function setTrigram($trigram)
|
||||
{
|
||||
global $DB;
|
||||
$this->trigram = $trigram;
|
||||
$DB->prepare("UPDATE `teams` SET `trigram` = ? WHERE `id` = ?;")->execute([$trigram, $this->id]);
|
||||
}
|
||||
|
||||
public function getTournamentId()
|
||||
{
|
||||
return $this->tournament;
|
||||
}
|
||||
|
||||
public function setTournamentId($tournament)
|
||||
{
|
||||
global $DB;
|
||||
$this->tournament = $tournament;
|
||||
$DB->prepare("UPDATE `teams` SET `tournament` = ? WHERE `id` = ?;")->execute([$tournament, $this->id]);
|
||||
}
|
||||
|
||||
public function getEncadrants()
|
||||
{
|
||||
return $this->encadrants;
|
||||
}
|
||||
|
||||
public function setEncadrant($i, $encadrant)
|
||||
{
|
||||
global $DB;
|
||||
$this->encadrants[$i - 1] = $encadrant;
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->prepare("UPDATE `teams` SET `encadrant_$i` = ? WHERE `id` = ?;")->execute([$encadrant, $this->id]);
|
||||
}
|
||||
|
||||
public function getParticipants()
|
||||
{
|
||||
return $this->participants;
|
||||
}
|
||||
|
||||
public function setParticipant($i, $participant)
|
||||
{
|
||||
global $DB;
|
||||
$this->participants[$i - 1] = $participant;
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->prepare("UPDATE `teams` SET `participant_$i` = ? WHERE `id` = ?;")->execute([$participant, $this->id]);
|
||||
}
|
||||
|
||||
public function getInscriptionDate()
|
||||
{
|
||||
return $this->inscription_date;
|
||||
}
|
||||
|
||||
public function getValidationStatus()
|
||||
{
|
||||
return $this->validation_status;
|
||||
}
|
||||
|
||||
public function setValidationStatus($status)
|
||||
{
|
||||
global $DB;
|
||||
$this->validation_status = $status;
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$DB->prepare("UPDATE `teams` SET `validation_status` = ? WHERE `id` = ?;")->execute([$status->getName(), $this->id]);
|
||||
}
|
||||
|
||||
public function isSelectedForFinal()
|
||||
{
|
||||
return $this->final_selection;
|
||||
}
|
||||
|
||||
public function selectForFinal($selected)
|
||||
{
|
||||
global $DB;
|
||||
$this->final_selection = $selected;
|
||||
$DB->prepare("UPDATE `teams` SET `final_selection` = ? WHERE `id` = ?;")->execute([$selected, $this->id]);
|
||||
}
|
||||
|
||||
public function getAccessCode()
|
||||
{
|
||||
return $this->access_code;
|
||||
}
|
||||
|
||||
public function getYear()
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
class Tournament
|
||||
{
|
||||
private $id;
|
||||
private $name;
|
||||
private $size;
|
||||
private $place;
|
||||
private $price;
|
||||
private $description;
|
||||
private $date_start, $date_end;
|
||||
private $date_inscription;
|
||||
private $date_solutions;
|
||||
private $date_syntheses;
|
||||
private $final;
|
||||
private $year;
|
||||
|
||||
public function __construct($id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT * FROM `tournaments` WHERE `id` = ?;");
|
||||
$req->execute([htmlspecialchars($id)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
throw new InvalidArgumentException("Le tournoi spécifié n'existe pas.");
|
||||
|
||||
$this->id = $id;
|
||||
$this->name = $data["name"];
|
||||
$this->size = $data["size"];
|
||||
$this->place = $data["place"];
|
||||
$this->price = $data["price"];
|
||||
$this->description = $data["description"];
|
||||
$this->date_start = $data["date_start"];
|
||||
$this->date_end = $data["date_end"];
|
||||
$this->date_inscription = $data["date_inscription"];
|
||||
$this->date_solutions = $data["date_solutions"];
|
||||
$this->date_syntheses = $data["date_syntheses"];
|
||||
$this->final = $data["final"] == true;
|
||||
$this->year = $data["year"];
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
global $DB;
|
||||
$this->name = $name;
|
||||
$DB->prepare("UPDATE `tournaments` SET `name` = ? WHERE `id` = ?;")->execute([$name, $this->id]);
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function setSize($size)
|
||||
{
|
||||
global $DB;
|
||||
$this->size = $size;
|
||||
$DB->prepare("UPDATE `tournaments` SET `size` = ? WHERE `id` = ?;")->execute([$size, $this->id]);
|
||||
}
|
||||
|
||||
public function getPlace()
|
||||
{
|
||||
return $this->place;
|
||||
}
|
||||
|
||||
public function setPlace($place)
|
||||
{
|
||||
global $DB;
|
||||
$this->place = $place;
|
||||
$DB->prepare("UPDATE `tournaments` SET `place` = ? WHERE `id` = ?;")->execute([$place, $this->id]);
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice($price)
|
||||
{
|
||||
global $DB;
|
||||
$this->price = $price;
|
||||
$DB->prepare("UPDATE `tournaments` SET `price` = ? WHERE `id` = ?;")->execute([$price, $this->id]);
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($desc)
|
||||
{
|
||||
global $DB;
|
||||
$this->description = $desc;
|
||||
$DB->prepare("UPDATE `tournaments` SET `description` = ? WHERE `id` = ?;")->execute([$desc, $this->id]);
|
||||
}
|
||||
|
||||
public function getStartDate()
|
||||
{
|
||||
return $this->date_start;
|
||||
}
|
||||
|
||||
public function setStartDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_start = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_start` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getEndDate()
|
||||
{
|
||||
return $this->date_end;
|
||||
}
|
||||
|
||||
public function setEndDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_end = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_end` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getInscriptionDate()
|
||||
{
|
||||
return $this->date_inscription;
|
||||
}
|
||||
|
||||
public function setInscriptionDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_inscription = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_inscription` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getSolutionsDate()
|
||||
{
|
||||
return $this->date_solutions;
|
||||
}
|
||||
|
||||
public function setSolutionsDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_solutions = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_solutions` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function getSynthesesDate()
|
||||
{
|
||||
return $this->date_syntheses;
|
||||
}
|
||||
|
||||
public function setSynthesesDate($date)
|
||||
{
|
||||
global $DB;
|
||||
$this->date_syntheses = $date;
|
||||
$DB->prepare("UPDATE `tournaments` SET `date_syntheses` = ? WHERE `id` = ?;")->execute([$date, $this->id]);
|
||||
}
|
||||
|
||||
public function isFinal()
|
||||
{
|
||||
return $this->final;
|
||||
}
|
||||
|
||||
public function setFinal($final)
|
||||
{
|
||||
global $DB;
|
||||
$this->final = $final;
|
||||
$DB->prepare("UPDATE `tournaments` SET `final` = ? WHERE `id` = ?;")->execute([$final, $this->id]);
|
||||
}
|
||||
|
||||
public function getYear()
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,334 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
class User
|
||||
{
|
||||
private $id;
|
||||
private $email;
|
||||
private $pwd_hash;
|
||||
private $surname;
|
||||
private $first_name;
|
||||
private $birth_date;
|
||||
private $gender;
|
||||
private $address;
|
||||
private $postal_code;
|
||||
private $city;
|
||||
private $country;
|
||||
private $phone_number;
|
||||
private $school;
|
||||
private $class;
|
||||
private $responsible_name;
|
||||
private $responsible_phone;
|
||||
private $responsible_email;
|
||||
private $description;
|
||||
private $role;
|
||||
private $team_id;
|
||||
private $year;
|
||||
private $confirm_email;
|
||||
private $forgotten_password;
|
||||
|
||||
public function __construct($id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT * FROM `users` WHERE `id` = ?;");
|
||||
$req->execute([htmlspecialchars($id)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
throw new InvalidArgumentException("L'utilisateur spécifié n'existe pas.");
|
||||
|
||||
$this->id = $id;
|
||||
$this->email = $data["email"];
|
||||
$this->pwd_hash = $data["pwd_hash"];
|
||||
$this->surname = $data["surname"];
|
||||
$this->first_name = $data["first_name"];
|
||||
$this->birth_date = $data["birth_date"];
|
||||
$this->gender = $data["gender"];
|
||||
$this->address = $data["address"];
|
||||
$this->postal_code = $data["postal_code"];
|
||||
$this->city = $data["city"];
|
||||
$this->country = $data["country"];
|
||||
$this->phone_number = $data["phone_number"];
|
||||
$this->school = $data["school"];
|
||||
$this->class = $data["class"];
|
||||
$this->responsible_name = $data["responsible_name"];
|
||||
$this->responsible_phone = $data["responsible_phone"];
|
||||
$this->responsible_email = $data["responsible_email"];
|
||||
$this->description = $data["description"];
|
||||
$this->role = Role::fromName($data["role"]);
|
||||
$this->team_id = $data["team_id"];
|
||||
$this->year = $data["year"];
|
||||
$this->confirm_email = $data["confirm_email"];
|
||||
$this->forgotten_password = $data["forgotten_password"];
|
||||
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail($email)
|
||||
{
|
||||
global $DB;
|
||||
$this->email = $email;
|
||||
$DB->prepare("UPDATE `users` SET `email` = ?, WHERE `id` = ?;")->execute([$email, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function checkPassword($password)
|
||||
{
|
||||
return password_verify($password, $this->pwd_hash);
|
||||
}
|
||||
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->setPasswordHash(password_hash($password, PASSWORD_BCRYPT));
|
||||
}
|
||||
|
||||
private function setPasswordHash($password_hash)
|
||||
{
|
||||
global $DB;
|
||||
$this->pwd_hash = $password_hash;
|
||||
$DB->prepare("UPDATE `users` SET `pwd_hash` = ?, WHERE `id` = ?;")->execute([$password_hash, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getSurname()
|
||||
{
|
||||
return $this->surname;
|
||||
}
|
||||
|
||||
public function setSurname($surname)
|
||||
{
|
||||
global $DB;
|
||||
$this->surname = $surname;
|
||||
$DB->prepare("UPDATE `users` SET `surname` = ?, WHERE `id` = ?;")->execute([$surname, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getFirstName()
|
||||
{
|
||||
return $this->first_name;
|
||||
}
|
||||
|
||||
public function setFirstName($first_name)
|
||||
{
|
||||
global $DB;
|
||||
$this->first_name = $first_name;
|
||||
$DB->prepare("UPDATE `users` SET `first_name` = ?, WHERE `id` = ?;")->execute([$first_name, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getBirthDate()
|
||||
{
|
||||
return $this->birth_date;
|
||||
}
|
||||
|
||||
public function setBirthDate($birth_date)
|
||||
{
|
||||
global $DB;
|
||||
$this->birth_date = $birth_date;
|
||||
$DB->prepare("UPDATE `users` SET `birth_date` = ?, WHERE `id` = ?;")->execute([$birth_date, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getGender()
|
||||
{
|
||||
return $this->gender;
|
||||
}
|
||||
|
||||
public function setGender($gender)
|
||||
{
|
||||
global $DB;
|
||||
$this->gender = $gender;
|
||||
$DB->prepare("UPDATE `users` SET `email` = ?, WHERE `id` = ?;")->execute([$gender, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setAddress($address)
|
||||
{
|
||||
global $DB;
|
||||
$this->address = $address;
|
||||
$DB->prepare("UPDATE `users` SET `address` = ?, WHERE `id` = ?;")->execute([$address, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getPostalCode()
|
||||
{
|
||||
return $this->postal_code;
|
||||
}
|
||||
|
||||
public function setPostalCode($postal_code)
|
||||
{
|
||||
global $DB;
|
||||
$this->postal_code = $postal_code;
|
||||
$DB->prepare("UPDATE `users` SET `postal_code` = ?, WHERE `id` = ?;")->execute([$postal_code, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getCity()
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setCity($city)
|
||||
{
|
||||
global $DB;
|
||||
$this->city = $city;
|
||||
$DB->prepare("UPDATE `users` SET `city` = ?, WHERE `id` = ?;")->execute([$city, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function setCountry($country)
|
||||
{
|
||||
global $DB;
|
||||
$this->country = $country;
|
||||
$DB->prepare("UPDATE `users` SET `country` = ?, WHERE `id` = ?;")->execute([$country, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getPhoneNumber()
|
||||
{
|
||||
return $this->phone_number;
|
||||
}
|
||||
|
||||
public function setPhoneNumber($phone_number)
|
||||
{
|
||||
global $DB;
|
||||
$this->phone_number = $phone_number;
|
||||
$DB->prepare("UPDATE `users` SET `phone_number` = ?, WHERE `id` = ?;")->execute([$phone_number, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getSchool()
|
||||
{
|
||||
return $this->school;
|
||||
}
|
||||
|
||||
public function setSchool($school)
|
||||
{
|
||||
global $DB;
|
||||
$this->school = $school;
|
||||
$DB->prepare("UPDATE `users` SET `school` = ?, WHERE `id` = ?;")->execute([$school, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
public function setClass($class)
|
||||
{
|
||||
global $DB;
|
||||
$this->class = $class;
|
||||
$DB->prepare("UPDATE `users` SET `class` = ?, WHERE `id` = ?;")->execute([$class, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getResponsibleName()
|
||||
{
|
||||
return $this->responsible_name;
|
||||
}
|
||||
|
||||
public function setResponsibleName($responsible_name)
|
||||
{
|
||||
global $DB;
|
||||
$this->responsible_name = $responsible_name;
|
||||
$DB->prepare("UPDATE `users` SET `responsible_name` = ?, WHERE `id` = ?;")->execute([$responsible_name, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getResponsiblePhone()
|
||||
{
|
||||
return $this->responsible_phone;
|
||||
}
|
||||
|
||||
public function setResponsiblePhone($responsible_phone)
|
||||
{
|
||||
global $DB;
|
||||
$this->responsible_phone = $responsible_phone;
|
||||
$DB->prepare("UPDATE `users` SET `responsible_phone` = ?, WHERE `id` = ?;")->execute([$responsible_phone, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getResponsibleEmail()
|
||||
{
|
||||
return $this->responsible_email;
|
||||
}
|
||||
|
||||
public function setResponsibleEmail($responsible_email)
|
||||
{
|
||||
global $DB;
|
||||
$this->responsible_email = $responsible_email;
|
||||
$DB->prepare("UPDATE `users` SET `responsible_email` = ?, WHERE `id` = ?;")->execute([$responsible_email, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($desc)
|
||||
{
|
||||
global $DB;
|
||||
$this->description = $desc;
|
||||
$DB->prepare("UPDATE `users` SET `description` = ?, WHERE `id` = ?;")->execute([$desc, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getRole()
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
public function setRole($role)
|
||||
{
|
||||
global $DB;
|
||||
$this->role = $role;
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$DB->prepare("UPDATE `users` SET `email` = ?, WHERE `id` = ?;")->execute([$role->getName(), $this->getId()]);
|
||||
}
|
||||
|
||||
public function getTeamId()
|
||||
{
|
||||
return $this->team_id;
|
||||
}
|
||||
|
||||
public function setTeamId($team_id)
|
||||
{
|
||||
global $DB;
|
||||
$this->team_id = $team_id;
|
||||
$DB->prepare("UPDATE `users` SET `team_id` = ?, WHERE `id` = ?;")->execute([$team_id, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getYear()
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
public function getConfirmEmailToken()
|
||||
{
|
||||
return $this->confirm_email;
|
||||
}
|
||||
|
||||
public function setConfirmEmailToken($token)
|
||||
{
|
||||
global $DB;
|
||||
$this->confirm_email = $token;
|
||||
$DB->prepare("UPDATE `users` SET `confirm_email` = ?, WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getForgottenPasswordToken()
|
||||
{
|
||||
return $this->forgotten_password;
|
||||
}
|
||||
|
||||
public function setForgottenPasswordToken($token)
|
||||
{
|
||||
global $DB;
|
||||
$this->forgotten_password = $token;
|
||||
$DB->prepare("UPDATE `users` SET `forgotten_password` = ?, WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
class ValidationStatus extends SplEnum
|
||||
{
|
||||
const __default = self::NOT_READY;
|
||||
|
||||
const NOT_READY = 0;
|
||||
const WAITING = 1;
|
||||
const VALIDATED = 2;
|
||||
|
||||
public function getName() {
|
||||
switch ($this) {
|
||||
case self::WAITING:
|
||||
return "En attente de validation";
|
||||
case self::VALIDATED:
|
||||
return "Inscription validée";
|
||||
default:
|
||||
return "Inscription non terminée";
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromName($name) {
|
||||
switch ($name) {
|
||||
case "WAITING":
|
||||
return self::WAITING;
|
||||
case "VALIDATED":
|
||||
return self::VALIDATED;
|
||||
default:
|
||||
return self::NOT_READY;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue