add some classes files
continuous-integration/drone/push Build is passing Details

issue_16_statistics_coach
Antoine PEREDERII 1 year ago
parent 6f9d60fa27
commit f0cf8d96a4

File diff suppressed because it is too large Load Diff

@ -21,7 +21,8 @@
}, },
"require": { "require": {
"twig/twig": "^3.0", "twig/twig": "^3.0",
"vlucas/phpdotenv": "^5.5" "vlucas/phpdotenv": "^5.5",
"ext-cassandra": "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "*" "phpunit/phpunit": "*"

@ -0,0 +1,30 @@
<?php
namespace Model;
use Cassandra\Date;
use Cassandra\Time;
class Activity
{
private int $idActivity;
private String $type;
private Date $date;
private time $heureDebut;
private time $heureFin;
private int $effortRessenti;
private float $variability;
private float $variance;
private float $standardDeviation;
private float $average;
private int $maximum;
private int $minimum;
private float $avrTemperature;
private Data $arrayData;
private function getActivity():Activity{
return $this;
}
private function getAnalyse(Activity $activity):String{
return $this->arrayData[$activity]->__to_String();
}
}

@ -4,6 +4,36 @@ namespace Model;
class Athlete extends Role { class Athlete extends Role {
// Attributs spécifiques a l'athlete si nécessaire // Attributs spécifiques a l'athlete si nécessaire
private array $arrayStats = [];
private array $arrayActivities = [];
private array $arrayDateSources = [];
public function getAthlete():Athlete {
return $this;
}
public function getStat():?array{
return $this->arrayStats;
}
public function getActivite():?array{
return $this->arrayActivities;
}
public function getDataSource():?array{
return $this->arrayDateSources;
}
public function getUsersList(): array{
return $this->usersList;
}
private function CheckAdd(User $user)
{
if($user instanceof \Model\Athlete){
return true;
} else {
return false;
}
}
public function addUser(\Model\User $user): void public function addUser(\Model\User $user): void
{ {
if($this->CheckAdd($user)){ if($this->CheckAdd($user)){
@ -12,18 +42,14 @@ class Athlete extends Role {
echo "Impossible de demander en ami autre que des athletes\n"; echo "Impossible de demander en ami autre que des athletes\n";
} }
} }
private function CheckAdd(User $user) public function delUser(\Model\User $user):void{
{ if($this->CheckAdd($user)){
if($user instanceof \Model\Athlete){ $this->usersList[] = null;
return true;
} else { } else {
return false; echo "Impossible de demander en ami autre que des athletes\n";
} }
} }
public function getUsersList(): array{
return $this->usersList;
}
} }
?> ?>

@ -3,6 +3,7 @@
namespace Model; namespace Model;
class CoachAthlete extends Coach { class CoachAthlete extends Coach {
private Training $arrayTraining;
public function addUser(User $user): void { public function addUser(User $user): void {
if($this->CheckAdd($user)){ if($this->CheckAdd($user)){
$this->usersList[] = $user; $this->usersList[] = $user;

@ -0,0 +1,7 @@
<?php
namespace Model;
abstract class Data {
private int $idData;
}

@ -0,0 +1,20 @@
<?php
namespace Model;
use Cassandra\Date;
class DataSource
{
private int $idSource;
private enum $type;
private String $model;
private enum $precision;
private Date $dateLastUse;
public function getDataSource(DataSource $dataSource):String {
return $this->__to_String($dataSource);
}
public function __to_String(DataSource $dataSource):String{
return "Source de données :" . $dataSource;
}
}

@ -0,0 +1,32 @@
<?php
namespace Model;
use Cassandra\Time;
class HeartRate extends Data {
private float $altitude;
private time $time;
private int $bpm;
private float $longitude;
private float $latitude;
private float $temperature;
public function getAltitude():String{
return $this->altitude;
}
public function getTime():String{
return $this->time;
}
public function getBpm():String{
return $this->bpm;
}
public function getLongitude():String{
return $this->longitude;
}
public function getLatitude():String{
return $this->altitude;
}
public function getTemperature():String{
return $this->temperature;
}
}

@ -0,0 +1,25 @@
<?php
namespace Model;
use Cassandra\Time;
class Statistic
{
private int $idStatistic;
private float $totalDistance;
private float $weight;
private time $totalTime;
private int $avrHeartRate;
private int $minHeartRate;
private int $maxHeartRate;
private int $caloriesBurned;
public function getStatistic():Statistic{
return $this;
}
public function __toString(Statistic $stat):String{
return "Statistiques : " . $this->getStatistic();
}
}

@ -0,0 +1,31 @@
<?php
namespace Model;
use Cassandra\Date;
use SebastianBergmann\CodeCoverage\Report\Text;
class Training
{
private int $idTraining;
private Date $date;
private String $location;
private text $description;
private text $feedback;
public function getId():String {
return $this->getId();
}
public function getDate():String {
return $this->date;
}
public function getLocation():String {
return $this->location;
}
public function getDescription(): Text
{
return $this->description;
}
public function getFeedback():Text {
return $this->feedback;
}
}

@ -15,9 +15,15 @@ class CoachManager
function __construct(IAuthService $authService) function __construct(IAuthService $authService)
{ {
$this->authService = $authService; $this->authService = $authService;
echo "ntm putain de php";
echo $this->authService;
echo $this->authService->currentUser;
sleep(4);
// Assurez-vous que authService n'est pas null avant d'accéder à currentUser // Assurez-vous que authService n'est pas null avant d'accéder à currentUser
if ($this->authService && $this->authService->currentUser) { if ($this->authService->currentUser) {
echo "It's good, current user instencied";
sleep(4);
$this->currentUser = $this->authService->currentUser; $this->currentUser = $this->authService->currentUser;
} }
} }
@ -45,6 +51,7 @@ class CoachManager
// faire validation !!! // faire validation !!!
public function addUser(User $user): void public function addUser(User $user): void
{ {
echo $this->currentUser;
// Assurez-vous que currentUser n'est pas null avant d'accéder à getRole() // Assurez-vous que currentUser n'est pas null avant d'accéder à getRole()
if ($this->currentUser && $this->currentUser->getRole()) { if ($this->currentUser && $this->currentUser->getRole()) {
$this->currentUser->getRole()->addUser($user); $this->currentUser->getRole()->addUser($user);

@ -12,7 +12,7 @@ class UserRepository implements IUserRepository {
private array $users = []; private array $users = [];
public function __construct() { public function __construct() {
$this->users[] = new User(1, "Doe12", "Doe", "John", "john.doe@example.com", "password123", 'M', 1.80, 75, new \DateTime("1985-05-15"), new CoachAthlete()); $this->users[] = new User(1, "Doe", "Doe", "John", "john.doe@example.com", "password123", 'M', 1.80, 75, new \DateTime("1985-05-15"), new CoachAthlete());
$this->users[] = new User(2, "Smith", "Smith", "Jane", "jane.smith@example.com", "secure456", 'F', 1.65, 60, new \DateTime("1990-03-10"), new Athlete()); $this->users[] = new User(2, "Smith", "Smith", "Jane", "jane.smith@example.com", "secure456", 'F', 1.65, 60, new \DateTime("1990-03-10"), new Athlete());
$this->users[] = new User(3, "Martin", "Martin", "Paul", "paul.martin@example.com", "super789", 'M', 1.75, 68, new \DateTime("1988-08-20"), new CoachAthlete()); $this->users[] = new User(3, "Martin", "Martin", "Paul", "paul.martin@example.com", "super789", 'M', 1.75, 68, new \DateTime("1988-08-20"), new CoachAthlete());
$this->users[] = new User(4, "Brown", "Brown", "Anna", "anna.brown@example.com", "test000", 'F', 1.70, 58, new \DateTime("1992-11-25"), new Athlete()); $this->users[] = new User(4, "Brown", "Brown", "Anna", "anna.brown@example.com", "test000", 'F', 1.70, 58, new \DateTime("1992-11-25"), new Athlete());

Loading…
Cancel
Save