You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Web/Sources/src/data/model/Role.php

73 lines
1.6 KiB

<?php
namespace Model;
abstract class Role {
protected array $usersList = [];
protected array $usersRequests = [];
protected array $trainingList = [];
// Attributs spécifiques au Coach si nécessaire
public function getUsersList(): ?array
{
return $this->usersList;
}
public function getUsersRequests(): ?array
{
return $this->usersRequests;
}
public function addUsersRequests(RelationshipRequest $request): void
{
$this->usersRequests [] = $request;
}
public function removeRequest(RelationshipRequest $req): bool
{
$key = array_search($req, $this->usersRequests);
if ($key !== false) {
array_splice($this->usersRequests, $key, 1);
return true;
}
return false;
}
public abstract function CheckAdd(User $user) : bool;
public function addUser(User $user): bool
{
if($this->CheckAdd($user)){
array_push($this->usersList, $user);
return true;
}
return false;
}
/**
* @param User $user
* @return bool
*/
public function removeUser(User $user): bool
{
if($this->CheckAdd($user)){
$key = array_search($user, $this->usersList);
if ($key !== false) {
array_splice($this->usersList, $key, 1);
return true;
}
}
return false;
}
public function addTraining(Training $training)
{
$this->trainingList [] = $training;
return true;
}
public function getTrainingsList(): array
{
return $this->trainingList;
}
}
?>