merged_PLE
Paul LEVRAULT 1 year ago
parent 3fe8bde432
commit 4aff3b5a58

@ -0,0 +1,28 @@
<?php
namespace Database;
class EnvoiEntity {
private $idAthlete;
private $idNotif;
// Getters
public function getIdAthlete() :int {
return $this->idActivity;
}
public function getIdNotif() {
return $this->type;
}
// Setters
public function setIdAthlete($idAthlete) {
$this->idAthlete = $idAthlete;
}
public function setIdNotif($idNotif) {
$this->idNotif = $idNotif;
}
}
?>

@ -0,0 +1,25 @@
<?php
namespace Database;
class EnvoiGateway
{
private Connexion $connection;
public function __construct(Connexion $connection) {
$this->connection = $connection;
}
public function getEnvois(): array
{
$query = "SELECT * FROM Envoi";
$res = $this->connection->executeWithErrorHandling($query);
return $res;
}
public function addEnvoi(EnvoiEntity $envoi){
$query = "INSERT INTO Envoi (idAthlete, idEnvoi) VALUES (:idAthlete, :idEnvoi)";
$params = [':idAthlete'=>$envoi->getIdAthlete(), ':date'=>$idNotif->getIdNotif()];
return $this->connection->executeWithErrorHandling($query, $params);
}
}

@ -0,0 +1,44 @@
<?php
namespace Database;
class EnvoiMapper
{
public function envoiSqlToEntity(array $data): array
{
$envoiEntities = [];
foreach ($data as $envoiData) {
$envoi = new EnvoiEntity();
if (isset($envoiData['idNotif'])) {
$envoi->setIdNotif($envoiData['idNotif']);
}
if (isset($envoiData['idAthlete'])) {
$envoi->setMessage($envoiData['idAthlete']);
}
$envoiEntities[] = $envoi;
}
return $envoiEntities;
}
public function envoiEntityToModel(EnvoiEntity $envoiEntity): Envoi
{
$date = new DateTime($envoiEntity->getDate());
return new envoi(
$envoiEntity->getIdAthlete(),
$envoiEntity->getIdNotif(),
);
}
public function envoiToEntity(Envoi $envoi): EnvoiEntity
{
$notif = new envoiEntity();
$notif->setIdAthlete($envoi->getIdAthlete());
$notif->setIdNotif($envoi->getIdNotif());
return $notif;
}
}
Loading…
Cancel
Save