Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
|
8578d148a2 | 2 years ago |
|
689c7352e6 | 2 years ago |
|
c9082d0113 | 2 years ago |
|
d429a53b2d | 2 years ago |
|
ce4411500a | 2 years ago |
|
6269749bb1 | 2 years ago |
|
3d343a3777 | 2 years ago |
|
e484fe1d21 | 2 years ago |
|
e05546544f | 2 years ago |
|
0ad50347ea | 2 years ago |
|
3d31abede6 | 2 years ago |
|
55beea56d0 | 2 years ago |
@ -0,0 +1,75 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: HeartWave
|
||||||
|
|
||||||
|
# dev is DMZ
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# - name: test
|
||||||
|
# image: php:7.4
|
||||||
|
# commands:
|
||||||
|
# - cd Sources
|
||||||
|
# # Installe les dépendances PHP si nécessaire
|
||||||
|
# - composer install
|
||||||
|
# # - composer require phpunit/phpunit
|
||||||
|
# - vendor/bin/phpunit common/Tests
|
||||||
|
|
||||||
|
# build test X
|
||||||
|
- name: docker-build
|
||||||
|
image: php.8.2-apache
|
||||||
|
commands:
|
||||||
|
- cd folderA/
|
||||||
|
- npm run build:css
|
||||||
|
- build cmd
|
||||||
|
|
||||||
|
# Sonar static code analisis deployment ✔️
|
||||||
|
- name: code-analysis
|
||||||
|
image: php:8.2-cli
|
||||||
|
environment:
|
||||||
|
SONAR_TOKEN:
|
||||||
|
from_secret: SONAR_TOKEN
|
||||||
|
settings:
|
||||||
|
sources: ./Sources/
|
||||||
|
commands:
|
||||||
|
- export SONAR_SCANNER_VERSION=4.7.0.2747
|
||||||
|
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
|
||||||
|
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
|
||||||
|
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
||||||
|
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
|
||||||
|
- export SONAR_SCANNER_OPTS="-server"
|
||||||
|
- sonar-scanner -D sonar.projectKey=HeartTrack -D sonar.sources=./Sources -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
|
||||||
|
# -D sonar.flutter.coverage.reportPath=./Sources/bowlin_project/coverage/lcov.info
|
||||||
|
depends_on: [ docker-build ]
|
||||||
|
|
||||||
|
# build image and push on the registry ✔️
|
||||||
|
- name: docker-build-and-push
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: SECRET_REGISTRY_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: SECRET_REGISTRY_PASSWORD
|
||||||
|
dockerfile: Sources/config
|
||||||
|
context: Sources
|
||||||
|
registry: hub.codefirst.iut.uca.fr
|
||||||
|
repo: https://codefirst.iut.uca.fr/git/HeartDev/Web
|
||||||
|
depends_on: [ docker-build ]
|
||||||
|
|
||||||
|
- name: notify
|
||||||
|
image: ruby:2.1
|
||||||
|
rules:
|
||||||
|
- if: "$CI_COMMIT_TAG =~ /^.*-demo$/"
|
||||||
|
when: on_success
|
||||||
|
script:
|
||||||
|
- sh ./notifymail.sh
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db-data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
admin:
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
# not comited
|
@ -0,0 +1,27 @@
|
|||||||
|
.idea
|
||||||
|
.ben
|
||||||
|
.txt
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.vscode
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
.env
|
||||||
|
# Cache files for Sublime Text
|
||||||
|
*.tmlanguage.cache
|
||||||
|
*.tmPreferences.cache
|
||||||
|
*.stTheme.cache
|
||||||
|
|
||||||
|
# Workspace files are user-specific
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# Project files should be checked into the repository, unless a significant
|
||||||
|
# proportion of contributors will probably not be using Sublime Text
|
||||||
|
*.sublime-project
|
||||||
|
|
||||||
|
# SFTP configuration file
|
||||||
|
sftp-config.json
|
||||||
|
sftp-config-alt*.json
|
||||||
|
|
||||||
|
*.log*
|
||||||
|
coverage/
|
@ -0,0 +1,274 @@
|
|||||||
|
|
||||||
|
@startuml Diagramme de cas d'utilisation Clients
|
||||||
|
left to right direction
|
||||||
|
|
||||||
|
actor Coach as c
|
||||||
|
actor Sportif as s
|
||||||
|
s <|-- c
|
||||||
|
|
||||||
|
actor "Professionnel de la Santé" as HealthProfessional
|
||||||
|
package "Applications d'Analyse de Fréquence Cardiaque" {
|
||||||
|
|
||||||
|
package Web {
|
||||||
|
' ---------------------------------- Sportif ----------------------------------
|
||||||
|
|
||||||
|
usecase "Analyser Données de Fréquence Cardiaque" as UC1
|
||||||
|
usecase "Statistiques de Condition Physique" as UC2
|
||||||
|
usecase "Gestion Sociale" as UC3
|
||||||
|
usecase "Gérer Mes Informations de Compte" as UC4
|
||||||
|
usecase "Personnaliser Mon Profil Public" as UC19
|
||||||
|
usecase "Rechercher des Utilisateurs" as UC5
|
||||||
|
usecase "CRUD Amis" as UC6
|
||||||
|
usecase "Visualiser Analyse Fréquence Cardiaque" as UC26
|
||||||
|
usecase "Visualiser Activités" as UC7
|
||||||
|
usecase "Partager Mes Adnalyses" as UC8
|
||||||
|
usecase "Partager Mes Analyses avec Mon Coach" as UC9
|
||||||
|
usecase "Gérer la Visibilité de Mes Activités" as UC10
|
||||||
|
usecase "Synchroniser un Appareil d'Analyse de Fréquence Cardiaque" as UC11
|
||||||
|
usecase "Fournir un Fichier Contenant Mes Activités de Fréquence Cardiaque" as UC12
|
||||||
|
usecase "Synchroniser l'App Mobile" as UC13
|
||||||
|
usecase "Importer Données FIT/GPX/TCX" as UC14
|
||||||
|
usecase "Entrer à la Main Mes Informations de Fréquence Cardiaque" as UC15
|
||||||
|
usecase "Fournir Mes Données de Fréquence Cardiaque" as UC16
|
||||||
|
usecase "S'Inscrire" as UC17
|
||||||
|
usecase "Gérer Mes États de Connexion" as UC18
|
||||||
|
usecase "Supprimer Mon Compte" as UC19
|
||||||
|
usecase "Configurer Alertes" as UC20
|
||||||
|
usecase "Recevoir Alertes Anomalies" as UC21
|
||||||
|
usecase "Être Alerté en Cas de Problème de Santé" as UC22
|
||||||
|
|
||||||
|
' ---------------------------------- Coach ----------------------------------
|
||||||
|
|
||||||
|
usecase "Consulter les Statistiques de Ses Athlètes" as UC23
|
||||||
|
usecase "CRUD sur les Athlètes" as UC24
|
||||||
|
usecase "Alerter un Athlète en Cas de Problème de Santé" as UC25
|
||||||
|
usecase "Visualiser Analyse Fréquence Cardiaque Équipe" as UC26
|
||||||
|
usecase "Visualiser Activités Équipe" as UC27
|
||||||
|
|
||||||
|
' ---------------------------------- HealthProfessional ----------------------------------
|
||||||
|
|
||||||
|
usecase "Configurer Alertes Équipe" as UC28
|
||||||
|
usecase "Recevoir Alertes Anomalies Équipe" as UC29
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s --> UC1
|
||||||
|
s --> UC2
|
||||||
|
s --> UC3
|
||||||
|
s --> UC4
|
||||||
|
s --> UC5
|
||||||
|
s --> UC6
|
||||||
|
s --> UC7
|
||||||
|
s --> UC8
|
||||||
|
s --> UC9
|
||||||
|
s --> UC10
|
||||||
|
s --> UC11
|
||||||
|
s --> UC12
|
||||||
|
s --> UC13
|
||||||
|
s --> UC14
|
||||||
|
s --> UC15
|
||||||
|
s --> UC16
|
||||||
|
s --> UC17
|
||||||
|
s --> UC18
|
||||||
|
s --> UC19
|
||||||
|
s --> UC20
|
||||||
|
s --> UC21
|
||||||
|
s --> UC22
|
||||||
|
|
||||||
|
c --> UC23
|
||||||
|
c --> UC24
|
||||||
|
c --> UC25
|
||||||
|
c --> UC26
|
||||||
|
c --> UC27
|
||||||
|
|
||||||
|
|
||||||
|
HealthProfessional --> UC28
|
||||||
|
HealthProfessional --> UC29
|
||||||
|
|
||||||
|
UC5 --> UC6 : include
|
||||||
|
UC7 --> UC8 : include
|
||||||
|
UC8 --> UC9 : include
|
||||||
|
UC9 --> UC10 : include
|
||||||
|
UC10 --> UC11 : include
|
||||||
|
UC11 --> UC12 : include
|
||||||
|
UC13 --> UC14 : include
|
||||||
|
UC15 --> UC16 : include
|
||||||
|
UC18 --> UC19 : include
|
||||||
|
UC20 --> UC21 : include
|
||||||
|
UC21 --> UC22 : include
|
||||||
|
UC24 --> UC25 : include
|
||||||
|
UC26 --> UC27 : include
|
||||||
|
@enduml
|
||||||
|
|
||||||
|
@startuml
|
||||||
|
|
||||||
|
skinparam {
|
||||||
|
BackgroundColor LightYellow
|
||||||
|
ArrowColor Black
|
||||||
|
Shadowing false
|
||||||
|
BorderColor Black
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Models" {
|
||||||
|
|
||||||
|
class "Athlete" {
|
||||||
|
+ ID_Athlete : int
|
||||||
|
+ Name : string
|
||||||
|
+ Email : string
|
||||||
|
+ Password : string
|
||||||
|
+ PublicProfile : text
|
||||||
|
+ WeightHistory : string
|
||||||
|
+ Goals : text
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Coach" extends Athlete {
|
||||||
|
+ Specialization : string
|
||||||
|
}
|
||||||
|
|
||||||
|
class "SourceData" {
|
||||||
|
+ ID_Source : int
|
||||||
|
+ Type : string
|
||||||
|
+ Model : string
|
||||||
|
+ Precision : enum
|
||||||
|
+ PurchaseDate : date
|
||||||
|
+ LastUseDate : date
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Activity" {
|
||||||
|
+ ID_Activity : int
|
||||||
|
+ Type : string
|
||||||
|
+ Date : date
|
||||||
|
+ StartTime : time
|
||||||
|
+ EndTime : time
|
||||||
|
+ GPS_Position : string
|
||||||
|
+ Altitude : float
|
||||||
|
+ File : file
|
||||||
|
}
|
||||||
|
|
||||||
|
class "HeartRate" {
|
||||||
|
+ ID_HR : int
|
||||||
|
+ Time : time
|
||||||
|
+ BPM : int
|
||||||
|
+ Variability : float
|
||||||
|
+ Variance : float
|
||||||
|
+ StandardDeviation : float
|
||||||
|
+ Average : float
|
||||||
|
+ Max : int
|
||||||
|
+ Min : int
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Statistic" {
|
||||||
|
+ ID_Statistic : int
|
||||||
|
+ TotalDistance : float
|
||||||
|
+ TotalTime : time
|
||||||
|
+ AverageHR : int
|
||||||
|
+ MaxHR : int
|
||||||
|
+ CaloriesBurned : float
|
||||||
|
+ PersonalRecords : string
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Training" {
|
||||||
|
+ ID_Training : int
|
||||||
|
+ Date : date
|
||||||
|
+ Description : text
|
||||||
|
+ Exercises : text
|
||||||
|
+ Feedback : text
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Notification" {
|
||||||
|
+ ID_Notification : int
|
||||||
|
+ Message : text
|
||||||
|
+ Date : date
|
||||||
|
+ Status : enum
|
||||||
|
+ Type : string
|
||||||
|
+ Urgency : enum
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Event" {
|
||||||
|
+ ID_Event : int
|
||||||
|
+ Name : string
|
||||||
|
+ Description : text
|
||||||
|
+ Date : date
|
||||||
|
+ Location : string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Repositories" {
|
||||||
|
|
||||||
|
interface "IRepository<T>" {
|
||||||
|
+ find(id : int) : T
|
||||||
|
+ findAll() : List<T>
|
||||||
|
+ save(entity : T)
|
||||||
|
+ delete(entity : T)
|
||||||
|
}
|
||||||
|
|
||||||
|
class "AthleteRepository" implements "IRepository<Athlete>" {
|
||||||
|
}
|
||||||
|
|
||||||
|
class "ActivityRepository" implements "IRepository<Activity>" {
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... and so on for other entities ...
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Services" {
|
||||||
|
|
||||||
|
class "AthleteService" {
|
||||||
|
+ athleteRepo : AthleteRepository
|
||||||
|
+ findAll() : List<Athlete>
|
||||||
|
+ findById(id: int) : Athlete
|
||||||
|
+ save(athlete: Athlete) : bool
|
||||||
|
+ delete(athlete: Athlete) : bool
|
||||||
|
}
|
||||||
|
|
||||||
|
class "ActivityService" {
|
||||||
|
+ activityRepo : ActivityRepository
|
||||||
|
+ findAll() : List<Activity>
|
||||||
|
+ findByAthlete(athlete: Athlete) : List<Activity>
|
||||||
|
// ... and so on ...
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... Additional services for other entities ...
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Controllers" {
|
||||||
|
|
||||||
|
abstract class "BaseController" {
|
||||||
|
// Common controller methods and attributes
|
||||||
|
}
|
||||||
|
|
||||||
|
class "AthleteController" extends "BaseController" {
|
||||||
|
+ athleteService : AthleteService
|
||||||
|
+ showProfile(athleteId: int)
|
||||||
|
+ editProfile(athlete: Athlete)
|
||||||
|
+ listAthletes()
|
||||||
|
}
|
||||||
|
|
||||||
|
class "ActivityController" extends "BaseController" {
|
||||||
|
+ activityService : ActivityService
|
||||||
|
+ showActivities(athleteId: int)
|
||||||
|
+ addActivity(activity: Activity)
|
||||||
|
// ... and so on ...
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... Additional controllers for other entities ...
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseController <|-- AthleteController
|
||||||
|
BaseController <|-- ActivityController
|
||||||
|
|
||||||
|
Athlete --> Activity : "performs ->"
|
||||||
|
Coach --> Training : "assigns ->"
|
||||||
|
Activity --> HeartRate : "contains ->"
|
||||||
|
Athlete --> Notification : "receives ->"
|
||||||
|
Coach --> Event : "organizes ->"
|
||||||
|
Athlete --> Event : "participates in ->"
|
||||||
|
|
||||||
|
AthleteController --> AthleteService
|
||||||
|
ActivityController --> ActivityService
|
||||||
|
|
||||||
|
AthleteService --> AthleteRepository
|
||||||
|
ActivityService --> ActivityRepository
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,50 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
left to right direction
|
||||||
|
|
||||||
|
actor Coach as c
|
||||||
|
actor Sportif as s
|
||||||
|
|
||||||
|
package Dev {
|
||||||
|
|
||||||
|
actor HeartDev as d
|
||||||
|
package Monitoring {
|
||||||
|
usecase "Surveiller les services en temps réel" as UCM1
|
||||||
|
}
|
||||||
|
package Admin {
|
||||||
|
usecase "Administrer les données des utilisateurs" as UCA1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package Client {
|
||||||
|
|
||||||
|
package Web {
|
||||||
|
usecase "Analyser la fréquence cardiaque" as UC1
|
||||||
|
usecase "Statistiques de condition physique" as UC2
|
||||||
|
usecase "Gestion sociale" as UC3
|
||||||
|
usecase "Consulter les statistiques de ses athlètes" as UC4
|
||||||
|
}
|
||||||
|
|
||||||
|
package Mobile {
|
||||||
|
usecase "Récupérer les Activité et la fréquence cardiaque associées" as UCMobile1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package Server {
|
||||||
|
usecase "Fournir un web service pour les clients" as UCS1
|
||||||
|
usecase "Gérer la base de données" as UCS2
|
||||||
|
}
|
||||||
|
|
||||||
|
Web <|-- Mobile
|
||||||
|
s <|-- c
|
||||||
|
c --> UC4
|
||||||
|
s --> UC1
|
||||||
|
s --> UC2
|
||||||
|
s --> UC3
|
||||||
|
d --> UCM1
|
||||||
|
d --> UCA1
|
||||||
|
Web --> UCS1
|
||||||
|
Mobile --> UCS1
|
||||||
|
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,263 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
skinparam {
|
||||||
|
BackgroundColor LightYellow
|
||||||
|
ArrowColor Black
|
||||||
|
Shadowing false
|
||||||
|
BorderColor Black
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Router" {
|
||||||
|
class "AltoRouter" {
|
||||||
|
+match()
|
||||||
|
}
|
||||||
|
class "Request" {
|
||||||
|
+ method : string
|
||||||
|
+ uri : string
|
||||||
|
+ headers : array
|
||||||
|
+ body : string
|
||||||
|
+ getParameter(string) : string
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Response" {
|
||||||
|
+ statusCode : int
|
||||||
|
+ headers : array
|
||||||
|
+ body : string
|
||||||
|
+ setHeader(string, string) : void
|
||||||
|
+ setContent(string) : void
|
||||||
|
}
|
||||||
|
|
||||||
|
class "RedirectResponse" {
|
||||||
|
+ targetUrl : string
|
||||||
|
+ setTargetUrl(string) : void
|
||||||
|
}
|
||||||
|
|
||||||
|
interface "Action" {
|
||||||
|
+ execute(Request) : Response
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Controllers" {
|
||||||
|
abstract class "BaseController" {
|
||||||
|
- redirect(string, int) : RedirectResponse
|
||||||
|
- redirectToRoute(string, array, int) : RedirectResponse
|
||||||
|
- renderView(string, array) : string
|
||||||
|
- render(string, array, Response) : Response
|
||||||
|
- doRenderView(string, string?, array, string) : string
|
||||||
|
- doRender(string, string?, array, Response, string) : Response
|
||||||
|
+ abstract index()
|
||||||
|
+ abstract show($id)
|
||||||
|
}
|
||||||
|
|
||||||
|
class "AthleteController"{
|
||||||
|
+ index()
|
||||||
|
+ show($id)
|
||||||
|
+ create()
|
||||||
|
+ update($id)
|
||||||
|
+viewProfile()
|
||||||
|
+updateProfile()
|
||||||
|
}
|
||||||
|
|
||||||
|
class HeartRateController {
|
||||||
|
+model: HeartRateMonitor
|
||||||
|
+view: IView
|
||||||
|
+fetchAndDisplayData(): void
|
||||||
|
}
|
||||||
|
|
||||||
|
class "CoachController" {
|
||||||
|
+ index()
|
||||||
|
+ show($id)
|
||||||
|
+assignTraining()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
package "Services" {
|
||||||
|
class "AthleteService" {
|
||||||
|
+createAthlete()
|
||||||
|
+updateProfile()
|
||||||
|
}
|
||||||
|
class "TrainingService" {
|
||||||
|
+assignTraining()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface "NotificationStrategy" {
|
||||||
|
+sendNotification()
|
||||||
|
}
|
||||||
|
class "EmailNotification" {
|
||||||
|
}
|
||||||
|
class "PushNotification" {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Factories" {
|
||||||
|
class "AthleteFactory" {
|
||||||
|
+createAthlete() : Athlete
|
||||||
|
}
|
||||||
|
class WatchFactory {
|
||||||
|
+createWatch(model: string, user: User): Watch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Models" {
|
||||||
|
class "Athlete" {
|
||||||
|
+ ID_Athlete : int
|
||||||
|
+ Name : string
|
||||||
|
+ Email : string
|
||||||
|
+ Password : string
|
||||||
|
+ PublicProfile : text
|
||||||
|
+ WeightHistory : string
|
||||||
|
+ Goals : text
|
||||||
|
+registerObserver()
|
||||||
|
+removeObserver()
|
||||||
|
+notifyObservers()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface "Observer" {
|
||||||
|
+update()
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Coach" extends Athlete {
|
||||||
|
}
|
||||||
|
class "Notification" implements Observer {
|
||||||
|
+update()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IHeartRateDataProvider {
|
||||||
|
+getHeartRateData(): HeartRateData
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IHeartRateDataObserver {
|
||||||
|
+update(data: HeartRateData): void
|
||||||
|
}
|
||||||
|
|
||||||
|
class HeartRateData {
|
||||||
|
+dataId: int
|
||||||
|
+timestamp: datetime
|
||||||
|
+heartRate: int
|
||||||
|
+location: Location
|
||||||
|
+activity: Activity
|
||||||
|
}
|
||||||
|
|
||||||
|
class Location {
|
||||||
|
+latitude: double
|
||||||
|
+longitude: double
|
||||||
|
+altitude: double
|
||||||
|
}
|
||||||
|
|
||||||
|
class Watch extends SourceData{
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IHeartRateZoneProvider {
|
||||||
|
+getHeartRateZones(): HeartRateZone[]
|
||||||
|
}
|
||||||
|
|
||||||
|
class HeartRateZoneProvider implements IHeartRateZoneProvider {
|
||||||
|
+getHeartRateZones(): HeartRateZone[]
|
||||||
|
}
|
||||||
|
|
||||||
|
class HeartRateMonitor implements IHeartRateDataProvider, Subject {
|
||||||
|
+deviceId: int
|
||||||
|
+name: string
|
||||||
|
+serialNumber: string
|
||||||
|
+user: User
|
||||||
|
+heartRateData: HeartRateData[]
|
||||||
|
+attach(observer: Observer): void
|
||||||
|
+detach(observer: Observer): void
|
||||||
|
+notifyObservers(): void
|
||||||
|
+getHeartRateData(): HeartRateData
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Activity" {
|
||||||
|
+ ID_Activity : int
|
||||||
|
+ Type : string
|
||||||
|
+ Date : date
|
||||||
|
+ StartTime : time
|
||||||
|
+ EndTime : time
|
||||||
|
+ GPS_Position : string
|
||||||
|
+ Altitude : float
|
||||||
|
+ File : file
|
||||||
|
}
|
||||||
|
|
||||||
|
class "HeartRate" {
|
||||||
|
+ ID_HR : int
|
||||||
|
+ Time : time
|
||||||
|
+ BPM : int
|
||||||
|
+ Variability : float
|
||||||
|
+ Variance : float
|
||||||
|
+ StandardDeviation : float
|
||||||
|
+ Average : float
|
||||||
|
+ Max : int
|
||||||
|
+ Min : int
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Statistic" {
|
||||||
|
+ ID_Statistic : int
|
||||||
|
+ TotalDistance : float
|
||||||
|
+ TotalTime : time
|
||||||
|
+ AverageHR : int
|
||||||
|
+ MaxHR : int
|
||||||
|
+ CaloriesBurned : float
|
||||||
|
+ PersonalRecords : string
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Training" {
|
||||||
|
+ ID_Training : int
|
||||||
|
+ Date : date
|
||||||
|
+ Description : text
|
||||||
|
+ Exercises : text
|
||||||
|
+ Feedback : text
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Notification" {
|
||||||
|
+ ID_Notification : int
|
||||||
|
+ Message : text
|
||||||
|
+ Date : date
|
||||||
|
+ Status : enum
|
||||||
|
+ Type : string
|
||||||
|
+ Urgency : enum
|
||||||
|
}
|
||||||
|
|
||||||
|
class "Event" {
|
||||||
|
+ ID_Event : int
|
||||||
|
+ Name : string
|
||||||
|
+ Description : text
|
||||||
|
+ Date : date
|
||||||
|
+ Location : string
|
||||||
|
}
|
||||||
|
class "SourceData" {
|
||||||
|
+ ID_Source : int
|
||||||
|
+ Type : string
|
||||||
|
+ Model : string
|
||||||
|
+ Precision : enum
|
||||||
|
+ PurchaseDate : date
|
||||||
|
+ LastUseDate : date
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
package "Repositories" {
|
||||||
|
|
||||||
|
interface "Repository" {
|
||||||
|
+findByID()
|
||||||
|
+save()
|
||||||
|
+delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
class "AthleteRepository" implements Repository {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AltoRouter --> AthleteController
|
||||||
|
AthleteController --> AthleteService
|
||||||
|
AthleteService --> AthleteFactory
|
||||||
|
AthleteFactory --> Athlete
|
||||||
|
AthleteService --> NotificationStrategy
|
||||||
|
|
||||||
|
Athlete --> AthleteRepository : uses
|
||||||
|
Athlete -right-> Observer : notifies
|
||||||
|
Notification --> Athlete : observes
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,56 @@
|
|||||||
|
@startuml Modèle de Domaine
|
||||||
|
|
||||||
|
!define ENTITY class
|
||||||
|
!define RELATION composition
|
||||||
|
|
||||||
|
package "Domaine de l'Application d'Analyse de Fréquence Cardiaque" {
|
||||||
|
|
||||||
|
ENTITY User {
|
||||||
|
+ UserID : int
|
||||||
|
+ Username : string
|
||||||
|
+ Email : string
|
||||||
|
+ Password : string
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY Watch {
|
||||||
|
+ WatchID : int
|
||||||
|
+ Model : string
|
||||||
|
+ Brand : string
|
||||||
|
+ UserID : int
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY HeartRateActivity {
|
||||||
|
+ ActivityID : int
|
||||||
|
+ UserID : int
|
||||||
|
+ WatchID : int
|
||||||
|
+ StartTime : datetime
|
||||||
|
+ Duration : int
|
||||||
|
+ Distance : float
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY HeartRateAnalysis {
|
||||||
|
+ AnalysisID : int
|
||||||
|
+ ActivityID : int
|
||||||
|
+ AverageHeartRate : int
|
||||||
|
+ MaxHeartRate : int
|
||||||
|
+ MinHeartRate : int
|
||||||
|
+ Variability : float
|
||||||
|
+ StandardDeviation : float
|
||||||
|
}
|
||||||
|
|
||||||
|
User --* Watch : Owns
|
||||||
|
|
||||||
|
User --* HeartRateActivity : Records
|
||||||
|
|
||||||
|
HeartRateActivity --* HeartRateAnalysis : Has
|
||||||
|
|
||||||
|
ENTITY Coach {
|
||||||
|
+ CoachID : int
|
||||||
|
+ UserID : int
|
||||||
|
+ PhoneNumber : string
|
||||||
|
}
|
||||||
|
|
||||||
|
User --o Coach : IsCoachedBy
|
||||||
|
|
||||||
|
}
|
||||||
|
@enduml
|
@ -0,0 +1,89 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
!define ENTITY entity
|
||||||
|
!define PK "<u>P</u>"
|
||||||
|
!define FK "<b>F</b>"
|
||||||
|
|
||||||
|
skinparam {
|
||||||
|
BackgroundColor LightYellow
|
||||||
|
ArrowColor Black
|
||||||
|
Shadowing false
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Base de Données PostgreSQL" {
|
||||||
|
|
||||||
|
ENTITY Utilisateur {
|
||||||
|
+ ID_Utilisateur INT (PK)
|
||||||
|
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Prenom VARCHAR(255)
|
||||||
|
Adresse_e_mail VARCHAR(255)
|
||||||
|
Mot_de_passe VARCHAR(255)
|
||||||
|
Date_de_naissance DATE
|
||||||
|
Autres_informations_de_profil TEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY Montre {
|
||||||
|
+ ID_Montre INT (PK)
|
||||||
|
|
||||||
|
Nom_de_la_montre VARCHAR(255)
|
||||||
|
Marque_de_la_montre VARCHAR(255)
|
||||||
|
Numero_de_serie VARCHAR(255)
|
||||||
|
ID_Utilisateur INT (FK)
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY Activite {
|
||||||
|
+ ID_Activite INT (PK)
|
||||||
|
|
||||||
|
Date_et_heure_de_debut TIMESTAMP
|
||||||
|
Date_et_heure_de_fin TIMESTAMP
|
||||||
|
Type_d_activite VARCHAR(255)
|
||||||
|
ID_Utilisateur INT (FK)
|
||||||
|
ID_Montre INT (FK)
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY AnalyseFrequenceCardiaque {
|
||||||
|
+ ID_Analyse INT (PK)
|
||||||
|
|
||||||
|
Frequence_cardiaque INT
|
||||||
|
Date_et_heure_de_l_analyse TIMESTAMP
|
||||||
|
Donnees_GPS TEXT
|
||||||
|
ID_Activite INT (FK)
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY Alerte {
|
||||||
|
+ ID_Alerte INT (PK)
|
||||||
|
|
||||||
|
Type_d_alerte VARCHAR(255)
|
||||||
|
Date_et_heure_de_l_alerte TIMESTAMP
|
||||||
|
Description_de_l_alerte TEXT
|
||||||
|
ID_Utilisateur INT (FK)
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY Ami {
|
||||||
|
+ ID_Amitie INT (PK)
|
||||||
|
|
||||||
|
ID_Utilisateur INT
|
||||||
|
ID_Ami INT (FK)
|
||||||
|
}
|
||||||
|
|
||||||
|
ENTITY Athlete {
|
||||||
|
+ ID_Athlete INT (PK)
|
||||||
|
|
||||||
|
ID_Utilisateur INT (FK)
|
||||||
|
ID_Coach INT (FK)
|
||||||
|
}
|
||||||
|
|
||||||
|
Utilisateur ||--o{ Montre : Possede
|
||||||
|
Utilisateur ||--o{ Activite : Realise
|
||||||
|
Activite ||--o{ AnalyseFrequenceCardiaque : Comprend
|
||||||
|
Utilisateur ||--o{ Alerte : Recoit
|
||||||
|
Utilisateur }--o{ Ami : EstAmiAvec
|
||||||
|
Utilisateur ||--o{ Athlete : EstAthlete
|
||||||
|
|
||||||
|
Montre }--o{ Activite : Appartient
|
||||||
|
Montre }--o{ AnalyseFrequenceCardiaque : Appartient
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,28 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
!define ENTITY entity
|
||||||
|
!define PK "<u>P</u>"
|
||||||
|
!define FK "<b>F</b>"
|
||||||
|
define PK primary key
|
||||||
|
!define FK foreign key
|
||||||
|
|
||||||
|
skinparam class {
|
||||||
|
BackgroundColor LightBlue
|
||||||
|
BorderColor Black
|
||||||
|
BackgroundColor LightYellow
|
||||||
|
ArrowColor Black
|
||||||
|
Shadowing false
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Modèle de Données" {
|
||||||
|
|
||||||
|
|
||||||
|
Utilisateur "1" -- "1" Montre : Possède
|
||||||
|
Utilisateur "1" -- "n" Activité : Réalise
|
||||||
|
Activité "1" -- "n" AnalyseFréquenceCardiaque : Comprend
|
||||||
|
Utilisateur "1" -- "n" Alerte : Reçoit
|
||||||
|
Utilisateur "n" -- "n" Ami : EstAmiAvec
|
||||||
|
Utilisateur "1" -- "0-1" Athlète : EstAthlète
|
||||||
|
|
||||||
|
|
||||||
|
Objet -> Objet : Message Réflexif
|
@ -0,0 +1,129 @@
|
|||||||
|
@startuml
|
||||||
|
skinparam {
|
||||||
|
BackgroundColor LightYellow
|
||||||
|
ArrowColor Black
|
||||||
|
Shadowing false
|
||||||
|
BorderColor Black
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Modèle de Données" {
|
||||||
|
|
||||||
|
entity "Athlète" as athlete {
|
||||||
|
+ ID_Athlète : int
|
||||||
|
--
|
||||||
|
Nom : string
|
||||||
|
Prénom : string
|
||||||
|
Email : string
|
||||||
|
Sexe
|
||||||
|
Taille : Float
|
||||||
|
Poids : Float
|
||||||
|
Mot_de_passe : string
|
||||||
|
// Profil_public : text
|
||||||
|
DateNaissance:Date
|
||||||
|
// Objectifs : text
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity "Coach" as coach {
|
||||||
|
+ ID_Athlète : int (PK, FK)
|
||||||
|
--
|
||||||
|
// Attributs spécifiques au Coach si nécessaire
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "SourceDonnée" as source {
|
||||||
|
+ ID_Source : int
|
||||||
|
--
|
||||||
|
Type : string (enum)
|
||||||
|
Modèle : string
|
||||||
|
|
||||||
|
Précision : enum
|
||||||
|
Date_d'achat : date
|
||||||
|
Date_dernière_utilisation : date
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Activité" as activity {
|
||||||
|
+ ID_Activité : int
|
||||||
|
--
|
||||||
|
Type : string
|
||||||
|
Date : date
|
||||||
|
Heure_de_début : time
|
||||||
|
Heure_de_fin : time
|
||||||
|
|
||||||
|
Effort_Ressenti: int
|
||||||
|
Variabilité : float
|
||||||
|
Variance : float
|
||||||
|
Ecart-type : float
|
||||||
|
Moyenne : float
|
||||||
|
Maximum : int
|
||||||
|
Minimum : int
|
||||||
|
Temperature_moyenne: float
|
||||||
|
// visibilité
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity "FréquenceCardiaque" as fc {
|
||||||
|
+ ID_FC : int
|
||||||
|
--
|
||||||
|
Altitude : float
|
||||||
|
Temps : time
|
||||||
|
Température: float
|
||||||
|
BPM : int
|
||||||
|
logitude:float
|
||||||
|
latidute: float
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity "Statistique" as stats {
|
||||||
|
+ ID_Statistique : int
|
||||||
|
--
|
||||||
|
Distance_totale : float
|
||||||
|
Poids: float
|
||||||
|
Temps_total : time
|
||||||
|
FC_moyenne : int
|
||||||
|
FC_max : int
|
||||||
|
Calories_brûlées : float
|
||||||
|
Records_personnels : string
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Entraînement" as training {
|
||||||
|
+ ID_Entrainement : int
|
||||||
|
--
|
||||||
|
Date : date
|
||||||
|
Description : text
|
||||||
|
// Exercices : text
|
||||||
|
Feedback : text
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Notification" as notification {
|
||||||
|
+ ID_Notification : int
|
||||||
|
--
|
||||||
|
Message : text
|
||||||
|
Date : date
|
||||||
|
Statut : enum
|
||||||
|
Type : string
|
||||||
|
Urgence : enum
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Événement" as event {
|
||||||
|
+ ID_Événement : int
|
||||||
|
--
|
||||||
|
Nom : string
|
||||||
|
Description : text
|
||||||
|
Date : date
|
||||||
|
Lieu : string
|
||||||
|
}
|
||||||
|
athlete <|-- coach : Spécialisation
|
||||||
|
athlete --o{ source : Utilise
|
||||||
|
athlete --o{ activity : Effectue
|
||||||
|
source --o{ activity : Fournit
|
||||||
|
activity --o{ fc : Contient
|
||||||
|
athlete }o--o{ athlete : Est ami avec
|
||||||
|
athlete --o{ stats : A des
|
||||||
|
coach --o{ training : Attribue
|
||||||
|
athlete --o{ training : Reçoit
|
||||||
|
athlete --o{ notification : Reçoit
|
||||||
|
athlete --o{ event : Participe à
|
||||||
|
coach --o{ event : Organise
|
||||||
|
}
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,64 @@
|
|||||||
|
@startuml
|
||||||
|
package "Models" {
|
||||||
|
class "Athlete" {
|
||||||
|
+ ID_Athlete : int
|
||||||
|
+ Name : string
|
||||||
|
+ Email : string
|
||||||
|
+ Password : string
|
||||||
|
+ PublicProfile : text
|
||||||
|
+ WeightHistory : string
|
||||||
|
+ Goals : text
|
||||||
|
+registerObserver()
|
||||||
|
+removeObserver()
|
||||||
|
+notifyObservers()
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class DataManager{
|
||||||
|
|
||||||
|
}
|
||||||
|
class StubManager extends DataManager{
|
||||||
|
|
||||||
|
}
|
||||||
|
class PlainManager extends DataManager{
|
||||||
|
|
||||||
|
}
|
||||||
|
interface GenericDataManager {
|
||||||
|
+getItems() : List<T>
|
||||||
|
+getItemById(id: Int) : T
|
||||||
|
}
|
||||||
|
class AthleteManager implements GenericDataManager{
|
||||||
|
+getItemsByName(substring: String) : List<Team>
|
||||||
|
}
|
||||||
|
class ActivityManager implements GenericDataManager{
|
||||||
|
+getItemsByName(substring: String) : List<Team>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
package "Services" {
|
||||||
|
class "AthleteService" {
|
||||||
|
+createAthlete()
|
||||||
|
+updateProfile()
|
||||||
|
}
|
||||||
|
class "AuthService" {
|
||||||
|
+login()
|
||||||
|
+register()
|
||||||
|
+signInWithGoogle()
|
||||||
|
+signOut()
|
||||||
|
}
|
||||||
|
interface "NotificationStrategy" {
|
||||||
|
+sendNotification()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
DataManager --> "-activityMgr" ActivityManager
|
||||||
|
DataManager --> "-activityMgr" ActivityManager
|
||||||
|
DataManager --> "-athleteMgr" AthleteManager
|
||||||
|
DataManager --> "+UserCurrent" Athlete
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,92 @@
|
|||||||
|
@startuml MCD Simplifier (base)
|
||||||
|
!define PK <<PK>>
|
||||||
|
!define FK <<FK>>
|
||||||
|
|
||||||
|
|
||||||
|
entity Montre {
|
||||||
|
MontreID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Marque VARCHAR(255)
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Activite {
|
||||||
|
ActiviteID PK
|
||||||
|
DateHeureDebut TIMESTAMP
|
||||||
|
DateHeureFin TIMESTAMP
|
||||||
|
MontreID FK
|
||||||
|
UtilisateurID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity DonneeFrequenceCardiaque {
|
||||||
|
DonneeID PK
|
||||||
|
FrequenceCardiaque INTEGER
|
||||||
|
DateHeure TIMESTAMP
|
||||||
|
Latitude DECIMAL(10, 6)
|
||||||
|
Longitude DECIMAL(10, 6)
|
||||||
|
Altitude DECIMAL(10, 2)
|
||||||
|
MontreID FK
|
||||||
|
ActiviteID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Coach {
|
||||||
|
CoachID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Prenom VARCHAR(255)
|
||||||
|
Email VARCHAR(255)
|
||||||
|
MotDePasse VARCHAR(255)
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Athlete {
|
||||||
|
AthleteID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Prenom VARCHAR(255)
|
||||||
|
Email VARCHAR(255)
|
||||||
|
MotDePasse VARCHAR(255)
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Alertes {
|
||||||
|
AlerteID PK
|
||||||
|
Description TEXT
|
||||||
|
DateHeure TIMESTAMP
|
||||||
|
UtilisateurID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Statistiques {
|
||||||
|
StatistiqueID PK
|
||||||
|
Moyenne INTEGER
|
||||||
|
Maximum INTEGER
|
||||||
|
Minimum INTEGER
|
||||||
|
Variabilite INTEGER
|
||||||
|
Variance INTEGER
|
||||||
|
EcartType INTEGER
|
||||||
|
ActiviteID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Groupe {
|
||||||
|
GroupeID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Description TEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
entity MembreGroupe {
|
||||||
|
MembreID PK
|
||||||
|
UtilisateurID FK
|
||||||
|
GroupeID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Coach --|{ Athlete : Entraine
|
||||||
|
Coach --|{ Activite : Visualise
|
||||||
|
Athlete --|{ Activite : Appartient
|
||||||
|
Montre --|{ Activite : Utilise
|
||||||
|
Montre --|{ DonneeFrequenceCardiaque : Fournit
|
||||||
|
Activite --|{ DonneeFrequenceCardiaque : Contient
|
||||||
|
Coach --|{ Alertes : Recoit
|
||||||
|
Athlete --|{ Alertes : Recoit
|
||||||
|
Athlete --|{ Statistiques : Affecte
|
||||||
|
Groupe --|{ MembreGroupe : Contient
|
||||||
|
Coach --|{ MembreGroupe : MembreDe
|
||||||
|
Athlete --|{ MembreGroupe : MembreDe
|
||||||
|
|
||||||
|
@enduml
|
||||||
|
|
@ -0,0 +1,122 @@
|
|||||||
|
@startuml
|
||||||
|
skinparam {
|
||||||
|
BackgroundColor LightYellow
|
||||||
|
ArrowColor Black
|
||||||
|
Shadowing false
|
||||||
|
BorderColor Black
|
||||||
|
}
|
||||||
|
|
||||||
|
package "Modèle de Données" {
|
||||||
|
|
||||||
|
entity "Athlète" as athlete {
|
||||||
|
+ ID_Athlète : int
|
||||||
|
--
|
||||||
|
Nom : string
|
||||||
|
Prénom : string
|
||||||
|
Email : string
|
||||||
|
Sexe : string
|
||||||
|
Taille : Float
|
||||||
|
Poids : Float
|
||||||
|
Mot_de_passe : string
|
||||||
|
DateNaissance: date
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Coach" as coach {
|
||||||
|
+ ID_Coach : int
|
||||||
|
--
|
||||||
|
ID_Athlète : int (FK)
|
||||||
|
// Attributs spécifiques au Coach si nécessaire
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "SourceDonnée" as source {
|
||||||
|
+ ID_Source : int
|
||||||
|
--
|
||||||
|
Type : string (enum)
|
||||||
|
Modèle : string
|
||||||
|
Précision : enum
|
||||||
|
Date_d'achat : date
|
||||||
|
Date_dernière_utilisation : date
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Activité" as activity {
|
||||||
|
+ ID_Activité : int
|
||||||
|
--
|
||||||
|
Type : string
|
||||||
|
Date : date
|
||||||
|
Heure_de_début : time
|
||||||
|
Heure_de_fin : time
|
||||||
|
Effort_Ressenti: int
|
||||||
|
Variabilité : float
|
||||||
|
Variance : float
|
||||||
|
Ecart-type : float
|
||||||
|
Moyenne : float
|
||||||
|
Maximum : int
|
||||||
|
Minimum : int
|
||||||
|
Temperature_moyenne: float
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "FréquenceCardiaque" as fc {
|
||||||
|
+ ID_FC : int
|
||||||
|
--
|
||||||
|
Altitude : float
|
||||||
|
Temps : time
|
||||||
|
Température: float
|
||||||
|
BPM : int
|
||||||
|
longitude: float
|
||||||
|
latitude: float
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Statistique" as stats {
|
||||||
|
+ ID_Statistique : int
|
||||||
|
--
|
||||||
|
Distance_totale : float
|
||||||
|
Poids: float
|
||||||
|
Temps_total : time
|
||||||
|
FC_moyenne : int
|
||||||
|
FC_max : int
|
||||||
|
Calories_brûlées : float
|
||||||
|
Records_personnels : string
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Entraînement" as training {
|
||||||
|
+ ID_Entrainement : int
|
||||||
|
--
|
||||||
|
Date : date
|
||||||
|
Description : text
|
||||||
|
Feedback : text
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Notification" as notification {
|
||||||
|
+ ID_Notification : int
|
||||||
|
--
|
||||||
|
Message : text
|
||||||
|
Date : date
|
||||||
|
Statut : enum
|
||||||
|
Type : string
|
||||||
|
Urgence : enum
|
||||||
|
}
|
||||||
|
|
||||||
|
entity "Événement" as event {
|
||||||
|
+ ID_Événement : int
|
||||||
|
--
|
||||||
|
Nom : string
|
||||||
|
Description : text
|
||||||
|
Date : date
|
||||||
|
Lieu : string
|
||||||
|
}
|
||||||
|
|
||||||
|
athlete <|-- coach : Spécialisation
|
||||||
|
athlete --o{ source : Utilise
|
||||||
|
athlete --o{ activity : Effectue
|
||||||
|
source --o{ activity : Fournit
|
||||||
|
activity --o{ fc : Contient
|
||||||
|
athlete }o--o{ athlete : Est ami avec
|
||||||
|
athlete --o{ stats : A des
|
||||||
|
coach --o{ training : Attribue
|
||||||
|
athlete --o{ training : Reçoit
|
||||||
|
athlete --o{ notification : Reçoit
|
||||||
|
athlete --o{ event : Participe à
|
||||||
|
coach --o{ event : Organise
|
||||||
|
}
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,101 @@
|
|||||||
|
@startuml Merise Model
|
||||||
|
!define PK <<PK>>
|
||||||
|
!define FK <<FK>>
|
||||||
|
|
||||||
|
|
||||||
|
entity Utilisateur {
|
||||||
|
UtilisateurID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Prenom VARCHAR(255)
|
||||||
|
Email VARCHAR(255)
|
||||||
|
MotDePasse VARCHAR(255)
|
||||||
|
DateDeNaissance DATE
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Montre {
|
||||||
|
MontreID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Marque VARCHAR(255)
|
||||||
|
UtilisateurID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Activite {
|
||||||
|
ActiviteID PK
|
||||||
|
DateHeureDebut TIMESTAMP
|
||||||
|
DateHeureFin TIMESTAMP
|
||||||
|
MontreID FK
|
||||||
|
UtilisateurID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity DonneeFrequenceCardiaque {
|
||||||
|
DonneeID PK
|
||||||
|
FrequenceCardiaque INTEGER
|
||||||
|
DateHeure TIMESTAMP
|
||||||
|
Latitude DECIMAL(10, 6)
|
||||||
|
Longitude DECIMAL(10, 6)
|
||||||
|
Altitude DECIMAL(10, 2)
|
||||||
|
MontreID FK
|
||||||
|
ActiviteID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Coach {
|
||||||
|
CoachID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Prenom VARCHAR(255)
|
||||||
|
Email VARCHAR(255)
|
||||||
|
MotDePasse VARCHAR(255)
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Athlete {
|
||||||
|
AthleteID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Prenom VARCHAR(255)
|
||||||
|
Email VARCHAR(255)
|
||||||
|
MotDePasse VARCHAR(255)
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Alertes {
|
||||||
|
AlerteID PK
|
||||||
|
Description TEXT
|
||||||
|
DateHeure TIMESTAMP
|
||||||
|
UtilisateurID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Statistiques {
|
||||||
|
StatistiqueID PK
|
||||||
|
Moyenne INTEGER
|
||||||
|
Maximum INTEGER
|
||||||
|
Minimum INTEGER
|
||||||
|
Variabilite INTEGER
|
||||||
|
Variance INTEGER
|
||||||
|
EcartType INTEGER
|
||||||
|
ActiviteID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
entity Groupe {
|
||||||
|
GroupeID PK
|
||||||
|
Nom VARCHAR(255)
|
||||||
|
Description TEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
entity MembreGroupe {
|
||||||
|
MembreID PK
|
||||||
|
UtilisateurID FK
|
||||||
|
GroupeID FK
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Utilisateur --|{ Montre : Possede
|
||||||
|
Utilisateur --|{ Activite : Realise
|
||||||
|
Montre --|{ Activite : Utilise
|
||||||
|
Montre --|{ DonneeFrequenceCardiaque : Fournit
|
||||||
|
Utilisateur --|{ Alertes : Recoit
|
||||||
|
Activite --|{ DonneeFrequenceCardiaque : Contient
|
||||||
|
Utilisateur --|{ Statistiques : Affecte
|
||||||
|
Coach --|{ Athlete : Entraine
|
||||||
|
Coach --|{ Activite : Visualise
|
||||||
|
Athlete --|{ Activite : Appartient
|
||||||
|
Groupe --|{ MembreGroupe : Contient
|
||||||
|
Utilisateur --|{ MembreGroupe : MembreDe
|
||||||
|
|
||||||
|
@enduml
|
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
@ -0,0 +1,115 @@
|
|||||||
|
<div align = center>
|
||||||
|
|
||||||
|
<img src="Documents/Images/logo.png" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div align = center>
|
||||||
|
|
||||||
|
[Présentation](#présentation) | [Répartion](#répartition-du-git) | [Développement](#développement) | [Wiki](https://codefirst.iut.uca.fr/git/HeartTrack_Dev/Web/wiki)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
</br>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
# HeartTrack
|
||||||
|
|
||||||
|
|
||||||
|
## Présentation
|
||||||
|
|
||||||
|
**Nom de l'application :** HeartTrack
|
||||||
|
|
||||||
|
### Contexte
|
||||||
|
|
||||||
|
HeartTrack est une application web PHP et mobile Android destinée aux sportifs pour l'analyse de courbes cardiaques. L'objectif principal de cette application est de récupérer les données de fréquence cardiaque à partir d'une montre, de les afficher sous forme de courbes, d'identifier des patterns, de fournir des statistiques et de réaliser des prédictions liées à l'effort physique, à la chaleur, à la récupération, etc.
|
||||||
|
|
||||||
|
### Récapitulatif du Projet
|
||||||
|
|
||||||
|
Le projet HeartTrack, avec son application HeartTrack, vise à offrir une solution complète pour l'analyse des données de fréquence cardiaque, en mettant l'accent sur les besoins des sportifs. L'application sera capable de traiter et d'interpréter les données de manière intelligente, fournissant ainsi des informations précieuses pour optimiser les performances sportives et la santé.
|
||||||
|
|
||||||
|
|
||||||
|
## Répartition du Git
|
||||||
|
|
||||||
|
[**Sources**](Sources) : **Code de l'application**
|
||||||
|
|
||||||
|
[**Documents**](Documents) : **Documentation de l'application**
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
Le projet HeartTrack utilise un modèle de flux de travail Git (Gitflow) pour organiser le développement. Voici une brève explication des principales branches :
|
||||||
|
|
||||||
|
- **branche prod** : Cette branche contient la version de production stable de l'application. Les modifications sur cette branche sont généralement destinées à des mises en production.
|
||||||
|
|
||||||
|
- **branche master** : La branche master est similaire à la branche de production, mais elle peut contenir des fonctionnalités en cours de développement qui sont presque prêtes pour une mise en production.
|
||||||
|
|
||||||
|
- **branche test** : Cette branche est utilisée pour déployer une version démo de l'application. Elle est mise à jour avec les dernières fonctionnalités et surtout la totalité de leurs test en développement.
|
||||||
|
|
||||||
|
- **branche issue** : Pour chaque problème (issue) que vous résolvez, vous devez créer une branche portant le nom de l'issue, par exemple, "issue_#32_nom" où 32 est le numéro de l'issue et nom est une description courte de l'issue. Une fois l'issue résolue, assurez-vous de mettre à jour le changelog et de créer une merge request.
|
||||||
|
|
||||||
|
|
||||||
|
## Développement
|
||||||
|
|
||||||
|
### Travailler sur une Issue
|
||||||
|
|
||||||
|
Si vous êtes amené à travailler sur une issue, suivez ces principes :
|
||||||
|
|
||||||
|
1. Les issues sont créées dans le système de gestion de versions (Git), chaque issue ayant un numéro unique.
|
||||||
|
|
||||||
|
2. Lorsque vous décidez de travailler sur une issue, attribuez-vous l'issue et créez une branche avec un nom correspondant à l'issue sous la forme suivante : "issue_#32_nom" où 32 est le numéro de l'issue et nom est son libellé.
|
||||||
|
|
||||||
|
3. Une fois que vous avez résolu l'issue dans votre branche, assurez-vous de mettre à jour le changelog avec les modifications apportées.
|
||||||
|
|
||||||
|
4. Ensuite, poussez votre branche sur le référentiel distant et créez une merge request pour que vos modifications soient examinées par les autres membres de l'équipe.
|
||||||
|
|
||||||
|
## Prérequis
|
||||||
|
|
||||||
|
Avant de commencer à travailler sur le projet HeartTrack, assurez-vous d'avoir les prérequis suivants installés :
|
||||||
|
|
||||||
|
- Serveur web (par exemple, Apache)
|
||||||
|
- PHP (version recommandée)
|
||||||
|
- Base de données (par exemple, MySQL)
|
||||||
|
- Git
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Pour installer et exécuter le projet HeartTrack, suivez ces étapes :
|
||||||
|
|
||||||
|
1. Clonez ce référentiel sur votre machine locale en utilisant la commande suivante :
|
||||||
|
`git clone https://codefirst.iut.uca.fr/git/FitDev/Projet_fit_web`
|
||||||
|
|
||||||
|
2. Configurez votre environnement de développement avec les prérequis mentionnés ci-dessus.
|
||||||
|
|
||||||
|
3. Copiez le fichier de configuration d'exemple et configurez les paramètres de l'application :
|
||||||
|
|
||||||
|
cp config/config.example.php config/config.php
|
||||||
|
|
||||||
|
4. Importez la structure de la base de données à partir du fichier SQL fourni :
|
||||||
|
|
||||||
|
mysql -u votre_nom_utilisateur -p < db_schema.sql
|
||||||
|
|
||||||
|
|
||||||
|
5. Démarrez votre serveur web et accédez à l'application via le navigateur.
|
||||||
|
|
||||||
|
## Exécution
|
||||||
|
|
||||||
|
Pour exécuter l'application, suivez les instructions d'installation ci-dessus. Une fois l'application configurée et le serveur web en cours d'exécution, accédez à l'application via votre navigateur web.
|
||||||
|
|
||||||
|
## Déploiement en Démo
|
||||||
|
|
||||||
|
Pour déployer une version de démonstration de l'application, utilisez la branche "demo" du référentiel. Cette branche est généralement mise à jour avec les dernières fonctionnalités en développement.
|
||||||
|
|
||||||
|
## Déploiement en Production
|
||||||
|
|
||||||
|
Pour déployer la version de production de l'application, utilisez la branche "prod" du référentiel.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
N'hésitez pas à contribuer au développement de HeartTrack en résolvant des issues ou en ajoutant de nouvelles fonctionnalités. Nous vous encourageons à suivre les principes et les pratiques décrites dans ce document pour un développement efficace et collaboratif.
|
@ -0,0 +1,4 @@
|
|||||||
|
vendor/
|
||||||
|
node_modules/
|
||||||
|
.env.local
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "hearttrack/package",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Core\\": "src/data/core/",
|
||||||
|
"Controller\\": "src/controller/",
|
||||||
|
"Stub\\": "src/data/stub/",
|
||||||
|
"Manager\\": "src/data/manager/",
|
||||||
|
"Repository\\": "src/data/core/repository/",
|
||||||
|
"Service\\": "src/data/core/network/service/",
|
||||||
|
"Shared\\": ["src/shared/request/", "src/shared/response/","src/shared/router/"] ,
|
||||||
|
"Utils\\": "src/utils/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"twig/twig": "^3.0"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,255 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "21490623fb644929ec5adaa8952849fb",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-ctype",
|
||||||
|
"version": "v1.28.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||||
|
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
|
||||||
|
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-ctype": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-ctype": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.28-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Ctype\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Gert de Pagter",
|
||||||
|
"email": "BackEndTea@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for ctype functions",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"ctype",
|
||||||
|
"polyfill",
|
||||||
|
"portable"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-01-26T09:26:14+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-mbstring",
|
||||||
|
"version": "v1.28.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||||
|
"reference": "42292d99c55abe617799667f454222c54c60e229"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229",
|
||||||
|
"reference": "42292d99c55abe617799667f454222c54c60e229",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-mbstring": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.28-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for the Mbstring extension",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"mbstring",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-07-28T09:04:16+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "twig/twig",
|
||||||
|
"version": "v3.7.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
|
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||||
|
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2.5",
|
||||||
|
"symfony/polyfill-ctype": "^1.8",
|
||||||
|
"symfony/polyfill-mbstring": "^1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"psr/container": "^1.0|^2.0",
|
||||||
|
"symfony/phpunit-bridge": "^5.4.9|^6.3"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Twig\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com",
|
||||||
|
"homepage": "http://fabien.potencier.org",
|
||||||
|
"role": "Lead Developer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Twig Team",
|
||||||
|
"role": "Contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Armin Ronacher",
|
||||||
|
"email": "armin.ronacher@active-4.com",
|
||||||
|
"role": "Project Founder"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||||
|
"homepage": "https://twig.symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"templating"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
|
"source": "https://github.com/twigphp/Twig/tree/v3.7.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2023-08-28T11:09:02+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
<Files *>
|
||||||
|
Order Allow,Deny
|
||||||
|
Deny from All
|
||||||
|
</Files>
|
@ -0,0 +1,13 @@
|
|||||||
|
# should change to nginx
|
||||||
|
FROM php:8.2-apache
|
||||||
|
|
||||||
|
WORKDIR /var/www/
|
||||||
|
|
||||||
|
COPY . /var/www/
|
||||||
|
|
||||||
|
RUN composer install
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# # Commande pour démarrer Apache
|
||||||
|
# CMD ["apache2-foreground"]
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// bdd var => should use .env var
|
||||||
|
const DB_HOST = $_ENV['DB_HOST'];
|
||||||
|
const DB_DATABASE = $_ENV['DB_DATABASE'];
|
||||||
|
const DB_USER = $_ENV['DB_USER'];
|
||||||
|
const DB_PASSWORD = $_ENV['DB_PASSWORD'];
|
||||||
|
$dsn ='mysql:host=londres.uca.local;dbname=dbdadalmeida1';
|
||||||
|
|
||||||
|
|
||||||
|
const VIEW_PATH = 'views';
|
@ -0,0 +1,9 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: ["../src/**/*.{html,js}"],
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "sources",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"test": "tests"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"tailwind" :"tailwindcss -i ./src/view/global.css -o ./dist/output.css --watch",
|
||||||
|
"build:css": "tailwindcss build ./src/view/global.css -o public/css/app.css"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"tailwindcss": "^3.3.3"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../config/config.php";
|
||||||
|
|
||||||
|
require '../vendor/autoload.php';
|
||||||
|
|
||||||
|
$app = App::getInstance();
|
||||||
|
|
||||||
|
$app->run();
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../../Config.php');
|
||||||
|
use Database\Connection;
|
||||||
|
class App
|
||||||
|
{
|
||||||
|
private static $instance;
|
||||||
|
private Router $router;
|
||||||
|
private Connection $dataBase;
|
||||||
|
private FrontController $frontController;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
$this->router = new Router();
|
||||||
|
$this->frontController = new FrontController($this->router);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (self::$instance === null) {
|
||||||
|
self::$instance = new self();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$this->frontController->dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Controllers;
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Controllers;
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
namespace Controllers;
|
||||||
|
|
||||||
|
class AthleteController extends BaseController
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Initialize UserController specific configurations or dependencies
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Handle the user listing logic here
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
// Handle displaying a specific user by ID
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
// Handle user creation logic here
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store()
|
||||||
|
{
|
||||||
|
// Handle storing a new user in the database
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
// Handle user editing logic here
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($id)
|
||||||
|
{
|
||||||
|
// Handle updating a user in the database
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
// Handle user deletion logic here
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
namespace Controllers;
|
||||||
|
use Responce\{RedirectResponse, Response};
|
||||||
|
/**
|
||||||
|
* BaseController is a abstract class that embede all based function of a controller in this app
|
||||||
|
* Responsabilité du contrôleur :
|
||||||
|
* - Gérer les demandes HTTP et coordonner l'exécution de l'action appropriée.
|
||||||
|
* - Exposer des méthodes/actions qui sont spécifiques à l'interface utilisateur.
|
||||||
|
* !!! Aucune logique métier ici !!!
|
||||||
|
* Contôle l'intégrité des données et valid les action ( les deux doivent être vérifier)
|
||||||
|
*/
|
||||||
|
abstract class BaseController{
|
||||||
|
protected function redirect(string $url, int $status = 302): RedirectResponse
|
||||||
|
{
|
||||||
|
return new RedirectResponse($url, $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||||
|
{
|
||||||
|
return $this->redirect($this->generateUrl($route, $parameters), $status);
|
||||||
|
}
|
||||||
|
protected function renderView(string $view, array $parameters = []): string
|
||||||
|
{
|
||||||
|
return $this->doRenderView($view, null, $parameters, __FUNCTION__);
|
||||||
|
}
|
||||||
|
protected function render(string $view, array $parameters = [], Response $response = null): Response
|
||||||
|
{
|
||||||
|
return $this->doRender($view, null, $parameters, $response, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function doRenderView(string $view, ?string $block, array $parameters, string $method): string
|
||||||
|
{
|
||||||
|
if (!$this->container->has('twig')) {
|
||||||
|
throw new \LogicException(sprintf('You cannot use the "%s" method if the Twig Bundle is not available. Try running "composer require symfony/twig-bundle".', $method));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($parameters as $k => $v) {
|
||||||
|
if ($v instanceof FormInterface) {
|
||||||
|
$parameters[$k] = $v->createView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $block) {
|
||||||
|
return $this->container->get('twig')->load($view)->renderBlock($block, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function doRender(string $view, ?string $block, array $parameters, ?Response $response, string $method): Response
|
||||||
|
{
|
||||||
|
$content = $this->doRenderView($view, $block, $parameters, $method);
|
||||||
|
$response ??= new Response();
|
||||||
|
|
||||||
|
if (200 === $response->getStatusCode()) {
|
||||||
|
foreach ($parameters as $v) {
|
||||||
|
if ($v instanceof FormInterface && $v->isSubmitted() && !$v->isValid()) {
|
||||||
|
$response->setStatusCode(422);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->setContent($content);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
abstract public function index();
|
||||||
|
|
||||||
|
abstract public function show($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Controllers;
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
// FrontController.php
|
||||||
|
class FrontController {
|
||||||
|
private $router;
|
||||||
|
|
||||||
|
public function __construct(Router $router) {
|
||||||
|
$this->router = $router;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dispatch() {
|
||||||
|
$match = $this->router->match();
|
||||||
|
|
||||||
|
if ($match) {
|
||||||
|
$controllerName = $match['controller'];
|
||||||
|
$actionName = $match['action'];
|
||||||
|
|
||||||
|
// Utilisez l'injection de dépendances pour créer le contrôleur
|
||||||
|
$controller = $this->createController($controllerName);
|
||||||
|
|
||||||
|
if ($controller) {
|
||||||
|
// Appeler l'action correspondante
|
||||||
|
$controller->$actionName();
|
||||||
|
} else {
|
||||||
|
// Gérer l'erreur, le contrôleur n'existe pas
|
||||||
|
$this->handleError();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Gérer l'erreur, aucune route correspondante
|
||||||
|
$this->handleError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createController($controllerName) {
|
||||||
|
// Utilisez un conteneur d'injection de dépendances pour créer le contrôleur
|
||||||
|
return DependencyContainer::create($controllerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleError() {
|
||||||
|
header("HTTP/1.0 404 Not Found");
|
||||||
|
echo "Page not found";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Controllers;
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
public function getArguments(Request $request, callable $controller, \ReflectionFunctionAbstract $reflector = null): array
|
||||||
|
{
|
||||||
|
$arguments = [];
|
||||||
|
|
||||||
|
foreach ($this->argumentMetadataFactory->createArgumentMetadata($controller, $reflector) as $metadata) {
|
||||||
|
$argumentValueResolvers = $this->argumentValueResolvers;
|
||||||
|
$disabledResolvers = [];
|
||||||
|
|
||||||
|
if ($this->namedResolvers && $attributes = $metadata->getAttributesOfType(ValueResolver::class, $metadata::IS_INSTANCEOF)) {
|
||||||
|
$resolverName = null;
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
if ($attribute->disabled) {
|
||||||
|
$disabledResolvers[$attribute->resolver] = true;
|
||||||
|
} elseif ($resolverName) {
|
||||||
|
throw new \LogicException(sprintf('You can only pin one resolver per argument, but argument "$%s" of "%s()" has more.', $metadata->getName(), $this->getPrettyName($controller)));
|
||||||
|
} else {
|
||||||
|
$resolverName = $attribute->resolver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolverName) {
|
||||||
|
if (!$this->namedResolvers->has($resolverName)) {
|
||||||
|
throw new ResolverNotFoundException($resolverName, $this->namedResolvers instanceof ServiceProviderInterface ? array_keys($this->namedResolvers->getProvidedServices()) : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
$argumentValueResolvers = [
|
||||||
|
$this->namedResolvers->get($resolverName),
|
||||||
|
new DefaultValueResolver(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($argumentValueResolvers as $name => $resolver) {
|
||||||
|
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($resolver->resolve($request, $metadata) as $argument) {
|
||||||
|
++$count;
|
||||||
|
$arguments[] = $argument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or there is a non-optional argument after this one.', $this->getPrettyName($controller), $metadata->getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arguments;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Exception;
|
||||||
|
|
||||||
|
final class NotImplementedException extends \Exception
|
||||||
|
{
|
||||||
|
protected $message = "Not implemented method call";
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
<?
|
||||||
|
namespace Shared;
|
@ -0,0 +1,5 @@
|
|||||||
|
<?
|
||||||
|
namespace Shared;
|
||||||
|
class RedirectResponse{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
<?
|
||||||
|
namespace Shared;
|
||||||
|
|
||||||
|
class Response{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,302 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2012 Danny van Kooten <hi@dannyvankooten.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AltoRouter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Array of all routes (incl. named routes).
|
||||||
|
*/
|
||||||
|
protected $routes = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Array of all named routes.
|
||||||
|
*/
|
||||||
|
protected $namedRoutes = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Can be used to ignore leading part of the Request URL (if main file lives in subdirectory of host)
|
||||||
|
*/
|
||||||
|
protected $basePath = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Array of default match types (regex helpers)
|
||||||
|
*/
|
||||||
|
protected $matchTypes = [
|
||||||
|
'i' => '[0-9]++',
|
||||||
|
'a' => '[0-9A-Za-z]++',
|
||||||
|
'h' => '[0-9A-Fa-f]++',
|
||||||
|
'*' => '.+?',
|
||||||
|
'**' => '.++',
|
||||||
|
'' => '[^/\.]++'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create router in one call from config.
|
||||||
|
*
|
||||||
|
* @param array $routes
|
||||||
|
* @param string $basePath
|
||||||
|
* @param array $matchTypes
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function __construct(array $routes = [], $basePath = '', array $matchTypes = [])
|
||||||
|
{
|
||||||
|
$this->addRoutes($routes);
|
||||||
|
$this->setBasePath($basePath);
|
||||||
|
$this->addMatchTypes($matchTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all routes.
|
||||||
|
* Useful if you want to process or display routes.
|
||||||
|
* @return array All routes.
|
||||||
|
*/
|
||||||
|
public function getRoutes()
|
||||||
|
{
|
||||||
|
return $this->routes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add multiple routes at once from array in the following format:
|
||||||
|
*
|
||||||
|
* $routes = [
|
||||||
|
* [$method, $route, $target, $name]
|
||||||
|
* ];
|
||||||
|
*
|
||||||
|
* @param array $routes
|
||||||
|
* @return void
|
||||||
|
* @author Koen Punt
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function addRoutes($routes)
|
||||||
|
{
|
||||||
|
if (!is_array($routes) && !$routes instanceof Traversable) {
|
||||||
|
throw new RuntimeException('Routes should be an array or an instance of Traversable');
|
||||||
|
}
|
||||||
|
foreach ($routes as $route) {
|
||||||
|
call_user_func_array([$this, 'map'], $route);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the base path.
|
||||||
|
* Useful if you are running your application from a subdirectory.
|
||||||
|
* @param string $basePath
|
||||||
|
*/
|
||||||
|
public function setBasePath($basePath)
|
||||||
|
{
|
||||||
|
$this->basePath = $basePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add named match types. It uses array_merge so keys can be overwritten.
|
||||||
|
*
|
||||||
|
* @param array $matchTypes The key is the name and the value is the regex.
|
||||||
|
*/
|
||||||
|
public function addMatchTypes(array $matchTypes)
|
||||||
|
{
|
||||||
|
$this->matchTypes = array_merge($this->matchTypes, $matchTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map a route to a target
|
||||||
|
*
|
||||||
|
* @param string $method One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)
|
||||||
|
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
|
||||||
|
* @param mixed $target The target where this route should point to. Can be anything.
|
||||||
|
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function map($method, $route, $target, $name = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->routes[] = [$method, $route, $target, $name];
|
||||||
|
|
||||||
|
if ($name) {
|
||||||
|
if (isset($this->namedRoutes[$name])) {
|
||||||
|
throw new RuntimeException("Can not redeclare route '{$name}'");
|
||||||
|
}
|
||||||
|
$this->namedRoutes[$name] = $route;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reversed routing
|
||||||
|
*
|
||||||
|
* Generate the URL for a named route. Replace regexes with supplied parameters
|
||||||
|
*
|
||||||
|
* @param string $routeName The name of the route.
|
||||||
|
* @param array @params Associative array of parameters to replace placeholders with.
|
||||||
|
* @return string The URL of the route with named parameters in place.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function generate($routeName, array $params = [])
|
||||||
|
{
|
||||||
|
|
||||||
|
// Check if named route exists
|
||||||
|
if (!isset($this->namedRoutes[$routeName])) {
|
||||||
|
throw new RuntimeException("Route '{$routeName}' does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace named parameters
|
||||||
|
$route = $this->namedRoutes[$routeName];
|
||||||
|
|
||||||
|
// prepend base path to route url again
|
||||||
|
$url = $this->basePath . $route;
|
||||||
|
|
||||||
|
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||||
|
foreach ($matches as $index => $match) {
|
||||||
|
list($block, $pre, $type, $param, $optional) = $match;
|
||||||
|
|
||||||
|
if ($pre) {
|
||||||
|
$block = substr($block, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params[$param])) {
|
||||||
|
// Part is found, replace for param value
|
||||||
|
$url = str_replace($block, $params[$param], $url);
|
||||||
|
} elseif ($optional && $index !== 0) {
|
||||||
|
// Only strip preceding slash if it's not at the base
|
||||||
|
$url = str_replace($pre . $block, '', $url);
|
||||||
|
} else {
|
||||||
|
// Strip match block
|
||||||
|
$url = str_replace($block, '', $url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match a given Request Url against stored routes
|
||||||
|
* @param string $requestUrl
|
||||||
|
* @param string $requestMethod
|
||||||
|
* @return array|boolean Array with route information on success, false on failure (no match).
|
||||||
|
*/
|
||||||
|
public function match($requestUrl = null, $requestMethod = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
// set Request Url if it isn't passed as parameter
|
||||||
|
if ($requestUrl === null) {
|
||||||
|
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
// strip base path from request url
|
||||||
|
$requestUrl = substr($requestUrl, strlen($this->basePath));
|
||||||
|
|
||||||
|
// Strip query string (?a=b) from Request Url
|
||||||
|
if (($strpos = strpos($requestUrl, '?')) !== false) {
|
||||||
|
$requestUrl = substr($requestUrl, 0, $strpos);
|
||||||
|
}
|
||||||
|
|
||||||
|
$lastRequestUrlChar = $requestUrl ? $requestUrl[strlen($requestUrl)-1] : '';
|
||||||
|
|
||||||
|
// set Request Method if it isn't passed as a parameter
|
||||||
|
if ($requestMethod === null) {
|
||||||
|
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->routes as $handler) {
|
||||||
|
list($methods, $route, $target, $name) = $handler;
|
||||||
|
|
||||||
|
$method_match = (stripos($methods, $requestMethod) !== false);
|
||||||
|
|
||||||
|
// Method did not match, continue to next route.
|
||||||
|
if (!$method_match) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($route === '*') {
|
||||||
|
// * wildcard (matches all)
|
||||||
|
$match = true;
|
||||||
|
} elseif (isset($route[0]) && $route[0] === '@') {
|
||||||
|
// @ regex delimiter
|
||||||
|
$pattern = '`' . substr($route, 1) . '`u';
|
||||||
|
$match = preg_match($pattern, $requestUrl, $params) === 1;
|
||||||
|
} elseif (($position = strpos($route, '[')) === false) {
|
||||||
|
// No params in url, do string comparison
|
||||||
|
$match = strcmp($requestUrl, $route) === 0;
|
||||||
|
} else {
|
||||||
|
// Compare longest non-param string with url before moving on to regex
|
||||||
|
// Check if last character before param is a slash, because it could be optional if param is optional too (see https://github.com/dannyvankooten/AltoRouter/issues/241)
|
||||||
|
if (strncmp($requestUrl, $route, $position) !== 0 && ($lastRequestUrlChar === '/' || $route[$position-1] !== '/')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$regex = $this->compileRoute($route);
|
||||||
|
$match = preg_match($regex, $requestUrl, $params) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($match) {
|
||||||
|
if ($params) {
|
||||||
|
foreach ($params as $key => $value) {
|
||||||
|
if (is_numeric($key)) {
|
||||||
|
unset($params[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'target' => $target,
|
||||||
|
'params' => $params,
|
||||||
|
'name' => $name
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile the regex for a given route (EXPENSIVE)
|
||||||
|
* @param $route
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function compileRoute($route)
|
||||||
|
{
|
||||||
|
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
||||||
|
$matchTypes = $this->matchTypes;
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
list($block, $pre, $type, $param, $optional) = $match;
|
||||||
|
|
||||||
|
if (isset($matchTypes[$type])) {
|
||||||
|
$type = $matchTypes[$type];
|
||||||
|
}
|
||||||
|
if ($pre === '.') {
|
||||||
|
$pre = '\.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$optional = $optional !== '' ? '?' : null;
|
||||||
|
|
||||||
|
//Older versions of PCRE require the 'P' in (?P<named>)
|
||||||
|
$pattern = '(?:'
|
||||||
|
. ($pre !== '' ? $pre : null)
|
||||||
|
. '('
|
||||||
|
. ($param !== '' ? "?P<$param>" : null)
|
||||||
|
. $type
|
||||||
|
. ')'
|
||||||
|
. $optional
|
||||||
|
. ')'
|
||||||
|
. $optional;
|
||||||
|
|
||||||
|
$route = str_replace($block, $pattern, $route);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "`^$route$`u";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Router{
|
||||||
|
private string $path = "/PHP/project/index.php";
|
||||||
|
|
||||||
|
private $router;
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
global $dir,$vues;
|
||||||
|
try{
|
||||||
|
session_start();
|
||||||
|
$tabError = array();
|
||||||
|
$this->router = new AltoRouter();
|
||||||
|
$this->router->setBasePath($this->path);
|
||||||
|
$this->initialiseRoutes();
|
||||||
|
|
||||||
|
|
||||||
|
$match = $this->router->match();
|
||||||
|
if(!$match){
|
||||||
|
$tabError[] = 'error : wrong path ';
|
||||||
|
|
||||||
|
require($dir . $vues['error']);
|
||||||
|
}
|
||||||
|
switch ($match['target']){
|
||||||
|
case 'UserControler' :
|
||||||
|
$this->userConnexion('UserControler', $match);
|
||||||
|
break;
|
||||||
|
case 'VisteurControler' :
|
||||||
|
$this->callController('VisteurControler', $match);
|
||||||
|
break;
|
||||||
|
case 'any':
|
||||||
|
|
||||||
|
VisteurControler::displayView();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$tabError[] = 'error : Wrong call router';
|
||||||
|
require($dir . $vues['error']);
|
||||||
|
}
|
||||||
|
}catch (PDOException $exp){
|
||||||
|
$tabError[] = 'error data base' . $exp->getMessage();
|
||||||
|
require($dir . $vues['error']);
|
||||||
|
} catch (Exception $exp2){
|
||||||
|
$tabError[] = 'unknow exeption' . $exp2->getMessage();
|
||||||
|
require($dir . $vues['error']);
|
||||||
|
}catch (Error $e){
|
||||||
|
$tabError[] = 'unknow error' . $e->getMessage();
|
||||||
|
require($dir . $vues['error']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function userConnexion(string $controller, array $match) : void{
|
||||||
|
global $dir, $vues;
|
||||||
|
|
||||||
|
if(ModelUser::isUser() != NULL){
|
||||||
|
$controller = 'UserControler';
|
||||||
|
$this->callController($controller, $match);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
VisteurControler::displayView();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function initialiseRoutes() : void{
|
||||||
|
$this->router->map( 'GET|POST', '/user/[a:action]?/[i:id]?', 'UserControler','user_action');
|
||||||
|
$this->router->map( 'GET|POST', '/', 'any');
|
||||||
|
$this->router->map( 'GET|POST', '/[a:action]/[i:id]?', 'VisteurControler','vistor_action');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function callController(string $controller, array $match) : void{
|
||||||
|
global $dir, $vues;
|
||||||
|
$action = Validation::val_action($match['params']['action']);
|
||||||
|
$controller = new $controller;
|
||||||
|
if(isset($match['params']['id'])){
|
||||||
|
$param[] = $match['params']['id'];
|
||||||
|
} else
|
||||||
|
$param[] = array();
|
||||||
|
if(is_callable(array($controller, $action)))
|
||||||
|
call_user_func_array(array($controller, $action), $param);
|
||||||
|
else{
|
||||||
|
$tabError[] = 'error : controller ';
|
||||||
|
require($dir . $vues['error']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function navigate(string $route, string $controller, array $match){return true;}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
namespace Utils;
|
||||||
|
class Validation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide une action passée en paramètre.
|
||||||
|
*
|
||||||
|
* @param string $action L'action à valider.
|
||||||
|
* @return string L'action validée si elle est conforme.
|
||||||
|
* @throws Exception Si l'action n'est pas valide.
|
||||||
|
*/
|
||||||
|
public static function val_action($action) {
|
||||||
|
if (!isset($action) || !Validation::val_string($action)) {
|
||||||
|
throw new Exception("Pas d'action spécifiée.");
|
||||||
|
} else {
|
||||||
|
return $action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide une chaîne de caractères.
|
||||||
|
*
|
||||||
|
* @param string $string La chaîne à valider.
|
||||||
|
* @return bool True si la chaîne est valide, sinon false.
|
||||||
|
* @throws Exception Si la chaîne n'est pas valide (tentative d'injection de code).
|
||||||
|
*/
|
||||||
|
public static function val_string(string $string) : bool {
|
||||||
|
if (filter_var($string, FILTER_SANITIZE_STRING) !== $string) {
|
||||||
|
throw new Exception("$string n'est pas valide. Tentative d'injection de code (attaque sécurité)!");
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide un entier.
|
||||||
|
*
|
||||||
|
* @param int $int L'entier à valider.
|
||||||
|
* @return bool True si l'entier est valide, sinon false.
|
||||||
|
* @throws Exception Si l'entier n'est pas valide (tentative d'injection de code).
|
||||||
|
*/
|
||||||
|
public static function val_int(int $int) : bool {
|
||||||
|
if (filter_var($int, FILTER_SANITIZE_NUMBER_INT) !== $int) {
|
||||||
|
throw new Exception("$int n'est pas valide. Tentative d'injection de code (attaque sécurité)!");
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide un mot de passe.
|
||||||
|
*
|
||||||
|
* @param string $password Le mot de passe à valider.
|
||||||
|
* @return bool True si le mot de passe est valide, sinon false.
|
||||||
|
* @throws Exception Si le mot de passe n'est pas valide.
|
||||||
|
*/
|
||||||
|
public static function val_password(string $password) : bool {
|
||||||
|
if ($password === null) {
|
||||||
|
throw new Exception("Le mot de passe ne peut être vide.");
|
||||||
|
} else {
|
||||||
|
if (!preg_match('/^.{6,}$/', $password)) {
|
||||||
|
throw new Exception("Le mot de passe n'est pas valide : au moins 6 caractères requis.");
|
||||||
|
}
|
||||||
|
return Validation::val_string($password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide un booléen.
|
||||||
|
*
|
||||||
|
* @param bool $done La valeur booléenne à valider.
|
||||||
|
* @return bool True si la valeur booléenne est définie, sinon false.
|
||||||
|
*/
|
||||||
|
public static function val_bool(bool $done) : bool {
|
||||||
|
return isset($done);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nettoie une chaîne de caractères.
|
||||||
|
*
|
||||||
|
* @param string $string La chaîne à nettoyer.
|
||||||
|
* @return string La chaîne nettoyée.
|
||||||
|
*/
|
||||||
|
public static function clean_string(string $string) : string {
|
||||||
|
return filter_var($string, FILTER_SANITIZE_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nettoie un entier.
|
||||||
|
*
|
||||||
|
* @param int $int L'entier à nettoyer.
|
||||||
|
* @return int L'entier nettoyé.
|
||||||
|
*/
|
||||||
|
public static function clean_int(int $int) : int {
|
||||||
|
return filter_var($int, FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nettoie une valeur booléenne.
|
||||||
|
*
|
||||||
|
* @param bool $bool La valeur booléenne à nettoyer.
|
||||||
|
* @return bool La valeur booléenne nettoyée.
|
||||||
|
*/
|
||||||
|
public static function clean_bool(bool $bool) : bool {
|
||||||
|
return filter_var($bool, FILTER_VALIDATE_BOOLEAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,4 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
/* should be build in a dist file such as official doc recommend */
|
@ -0,0 +1,77 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Activity Tracking</title>
|
||||||
|
<link href="/dist/output.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body class="bg-gray-900 text-white font-sans">
|
||||||
|
|
||||||
|
<div class="flex h-screen p-10">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="flex flex-col w-1/5 space-y-6">
|
||||||
|
<button class="p-3 bg-gray-800 rounded-full">
|
||||||
|
<!-- Your icon here -->
|
||||||
|
</button>
|
||||||
|
<!-- ... Repeat for other buttons ... -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Main content -->
|
||||||
|
<div class="flex flex-col w-4/5 space-y-6 pl-10">
|
||||||
|
<!-- Title -->
|
||||||
|
<h1 class="text-3xl">Activity Tracking</h1>
|
||||||
|
|
||||||
|
<!-- Activity Chart -->
|
||||||
|
<div class="p-6 bg-gray-800 rounded-lg">
|
||||||
|
<!-- Your chart here -->
|
||||||
|
<div class="relative">
|
||||||
|
<div class="flex justify-between items-center mb-4">
|
||||||
|
<p>Activity</p>
|
||||||
|
<div class="flex space-x-4">
|
||||||
|
<button class="text-gray-400">Plan</button>
|
||||||
|
<button class="text-green-500">My data</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Your chart component or SVG here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Water, Calories & Sleep Analytics -->
|
||||||
|
<div class="flex space-x-6">
|
||||||
|
<!-- Water -->
|
||||||
|
<div class="flex flex-col w-1/3 p-6 bg-gray-800 rounded-lg">
|
||||||
|
<p>Water</p>
|
||||||
|
<!-- Your water circle chart or SVG here -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Calories -->
|
||||||
|
<div class="flex flex-col w-1/3 p-6 bg-gray-800 rounded-lg">
|
||||||
|
<p>Calories</p>
|
||||||
|
<!-- Your calories chart or SVG here -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sleep Analytics -->
|
||||||
|
<div class="flex flex-col w-1/3 p-6 bg-gray-800 rounded-lg">
|
||||||
|
<p>Sleep Analytics</p>
|
||||||
|
<!-- Your sleep analytics component or SVG here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- General Indicators -->
|
||||||
|
<div class="p-6 bg-gray-800 rounded-lg">
|
||||||
|
<!-- Avatar and other indicators here -->
|
||||||
|
<div class="flex space-x-6">
|
||||||
|
<div class="w-1/3">
|
||||||
|
<!-- Avatar image or SVG here -->
|
||||||
|
</div>
|
||||||
|
<div class="w-2/3">
|
||||||
|
<!-- List of indicators here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,275 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Stub\StubData;
|
||||||
|
$model = new StubData();// Couche d'accès au model
|
||||||
|
|
||||||
|
function displayActivityMenu() {
|
||||||
|
echo "\n--- Gestion Activités ---\n";
|
||||||
|
echo "1. Importer des données (FIT/GPX/TCX)/Manuel\n";
|
||||||
|
echo "2. Synchroniser l'appareil de fréquence cardiaque\n";
|
||||||
|
echo "3. Synchroniser l'app mobile\n";
|
||||||
|
echo "4. Afficher les statistiques complète\n";
|
||||||
|
echo "5. Visualiser les jauges de fréquence cardiaque\n";
|
||||||
|
echo "6. Retour au menu principal\n";
|
||||||
|
echo "Choisissez une option: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
function activityActions() {
|
||||||
|
global $model;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
displayActivityMenu();
|
||||||
|
$activityChoice = trim(fgets(STDIN));
|
||||||
|
|
||||||
|
switch ($activityChoice) {
|
||||||
|
case '1': // Importer des données (FIT/GPX/TCX)/Manuel
|
||||||
|
echo "\nChoisissez le type de fichier à importer (FIT/GPX/TCX) ou tapez 'Manuel' pour une saisie manuelle : ";
|
||||||
|
$fileType = trim(fgets(STDIN));
|
||||||
|
|
||||||
|
switch (strtoupper($fileType)) {
|
||||||
|
case 'FIT':
|
||||||
|
case 'GPX':
|
||||||
|
case 'TCX':
|
||||||
|
// Importer le fichier correspondant
|
||||||
|
$model->ActivityMgr->importFile($fileType);
|
||||||
|
break;
|
||||||
|
case 'MANUEL':
|
||||||
|
// Import manuel des données
|
||||||
|
$model->ActivityMgr->manualDataEntry();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo "Type de fichier ou choix invalide.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2': // Synchroniser l'appareil de fréquence cardiaque
|
||||||
|
echo "\nSynchronisation de l'appareil de fréquence cardiaque en cours...\n";
|
||||||
|
$model->HeartRateDeviceMgr->sync();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '3': // Synchroniser l'app mobile
|
||||||
|
echo "\nSynchronisation de l'app mobile en cours...\n";
|
||||||
|
$model->MobileAppMgr->sync();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '4': // Afficher les statistiques complète
|
||||||
|
echo "\nStatistiques complètes :\n";
|
||||||
|
$model->StatisticsMgr->displayFullStats();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '5': // Visualiser les jauges de fréquence cardiaque
|
||||||
|
echo "\nVisualisation des jauges de fréquence cardiaque :\n";
|
||||||
|
$model->HeartRateGaugeMgr->displayGauges();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '6': // Retour au menu principal
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
echo "Option invalide. Veuillez réessayer.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function displaySocialMenu(){
|
||||||
|
echo "\n--- Gestion Sociale ---\n";
|
||||||
|
echo "1. Rechercher des utilisateurs\n";
|
||||||
|
echo "2. Ajoutez amis\n";
|
||||||
|
echo "2. Suprimez amis\n";
|
||||||
|
echo "2. Voir amis\n";
|
||||||
|
echo "3. Personnaliser le profil public\n";
|
||||||
|
echo "4. Partager mes analyses\n";
|
||||||
|
echo "5. Gérer la visibilité de mes activités\n";
|
||||||
|
echo "6. Retour au menu principal\n";
|
||||||
|
echo "Choisissez une option: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayMainAthleteMenu() {
|
||||||
|
echo "\n--- Menu Athlète ---\n";
|
||||||
|
echo "1. Voir le profil\n";
|
||||||
|
echo "2. Modifier le profil\n";
|
||||||
|
echo "10. Synchroniser un appareil\n";
|
||||||
|
echo "3. Visualiser l'analyse de fréquence cardiaque\n";
|
||||||
|
echo "4. Statistiques de condition physique\n";
|
||||||
|
echo "3. Gérer actvité \n";
|
||||||
|
|
||||||
|
echo "3. Retour au menu principal\n";
|
||||||
|
echo "Choisissez une option: ";
|
||||||
|
}
|
||||||
|
function displayMainCoachMenu() {
|
||||||
|
echo "\n--- Menu Coach ---\n";
|
||||||
|
echo "1. Voir le profil coach\n";
|
||||||
|
echo "2. Modifier le profil coach\n";
|
||||||
|
echo "8. Visualiser les performances de l'équipe\n";
|
||||||
|
echo "3. Retour au menu principal\n";
|
||||||
|
echo "3. Gérer Athlètes\n";
|
||||||
|
echo "Choisissez une option: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
function DisplayCoachAthleteMenu(){
|
||||||
|
echo "2. Ajoutez athlète\n";
|
||||||
|
echo "2. Supprimer athlète\n";
|
||||||
|
echo "2. Supprimer athlète\n";
|
||||||
|
echo "1. Consulter les statistiques d'un athlete \n";
|
||||||
|
|
||||||
|
echo "4. Retour au menu principal\n";
|
||||||
|
echo "Choisissez une option: ";
|
||||||
|
|
||||||
|
}
|
||||||
|
function clearScreen()
|
||||||
|
{
|
||||||
|
system('clear || cls');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function displayAuthMenu()
|
||||||
|
{
|
||||||
|
clearScreen();
|
||||||
|
echo "\n\n";
|
||||||
|
echo " +--------------------------+\n";
|
||||||
|
echo " | Menu Principal |\n";
|
||||||
|
echo " +--------------------------+\n";
|
||||||
|
echo " | 1. Se connecter |\n";
|
||||||
|
echo " | 2. S'inscrire |\n";
|
||||||
|
echo " | 0. Quitter |\n";
|
||||||
|
echo " +--------------------------+\n";
|
||||||
|
echo " Choisissez une option: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function loginUser() {
|
||||||
|
echo "\nEntrez votre nom d'utilisateur: ";
|
||||||
|
$username = trim(fgets(STDIN));
|
||||||
|
echo "Entrez votre mot de passe: ";
|
||||||
|
$password = trim(fgets(STDIN));
|
||||||
|
global $model;
|
||||||
|
if ($model->userMgr->login($username, $password)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
echo "Erreur de connexion. Essayez encore.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerUser() {
|
||||||
|
global $model;
|
||||||
|
echo "\nEntrez votre nom d'utilisateur: ";
|
||||||
|
$username = trim(fgets(STDIN));
|
||||||
|
echo "Entrez votre mot de passe: ";
|
||||||
|
$password = trim(fgets(STDIN));
|
||||||
|
$model->userMgr->register($username, $password);
|
||||||
|
echo "Utilisateur enregistré avec succès!\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function athleteActions() {
|
||||||
|
global $model;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
displayMainAthleteMenu();
|
||||||
|
$athleteChoice = trim(fgets(STDIN));
|
||||||
|
|
||||||
|
switch ($athleteChoice) {
|
||||||
|
case '1': // Voir le profil
|
||||||
|
echo "\nProfil de l'athlète:\n";
|
||||||
|
|
||||||
|
echo $model->userMgr->getCurrentUser() . "\n";
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2': // Modifier le profil
|
||||||
|
echo "\nModifier le profil:\n";
|
||||||
|
// Récupérer et modifier les informations de l'athlète
|
||||||
|
echo "Entrez le nouveau nom (ou laissez vide pour ne pas changer) : ";
|
||||||
|
$name = trim(fgets(STDIN));
|
||||||
|
echo "Entrez le nouvel âge (ou laissez vide pour ne pas changer) : ";
|
||||||
|
$age = trim(fgets(STDIN));
|
||||||
|
|
||||||
|
// Mettre à jour le profil dans le modèle avec accept NULL
|
||||||
|
$model->userMgr->updateProfile($name, $age);
|
||||||
|
echo "Profil mis à jour avec succès!\n";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '3': // Synchroniser un appareil
|
||||||
|
echo "\nSynchronisation de l'appareil en cours...\n";
|
||||||
|
// Supposons que vous ayez une fonction pour synchroniser un appareil
|
||||||
|
$model->DeviceMgr->syncDevice();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '4': // Visualiser l'analyse de fréquence cardiaque
|
||||||
|
// Supposons que vous ayez une fonction qui affiche une analyse
|
||||||
|
$model->HeartRateMgr->displayAnalysis();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '5': // Statistiques de condition physique
|
||||||
|
// Supposons que vous ayez une fonction qui affiche des statistiques
|
||||||
|
$model->FitnessMgr->displayStats();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '6': // Retour au menu principal
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
echo "Option invalide. Veuillez réessayer.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function coachActions() {
|
||||||
|
while (true) {
|
||||||
|
displayMainCoachMenu();
|
||||||
|
$coachChoice = trim(fgets(STDIN));
|
||||||
|
switch ($coachChoice) {
|
||||||
|
case '1': // Voir le profil coach
|
||||||
|
echo "Profil du coach...\n";
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
echo "Modifier le profil coach...\n";
|
||||||
|
break;
|
||||||
|
case '3': // Retour au menu principal
|
||||||
|
return;
|
||||||
|
case '4': // Gérer Athlètes
|
||||||
|
echo "Gérer Athlètes";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo "Option invalide. Veuillez réessayer.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
displayAuthMenu();
|
||||||
|
$choice = trim(fgets(STDIN));
|
||||||
|
|
||||||
|
switch ($choice) {
|
||||||
|
case '1': // Se connecter
|
||||||
|
if (loginUser()) {
|
||||||
|
if ($model->userMgr->getUser()::isCoach) {
|
||||||
|
coachActions();
|
||||||
|
} else {
|
||||||
|
athleteActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2': // S'inscrire
|
||||||
|
registerUser();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '0': // Quitter
|
||||||
|
echo "Merci d'avoir utilisé notre application. Au revoir !\n";
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
default:
|
||||||
|
echo "Option invalide. Veuillez réessayer.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
// echo "\nEntrez le chemin du fichier: ";
|
||||||
|
// $filePath = trim(fgets(STDIN));
|
||||||
|
// if ($model->importFile($filePath)) {
|
||||||
|
// echo "Fichier importé avec succès!\n";
|
||||||
|
// } else {
|
||||||
|
// echo "Erreur lors de l'importation du fichier.\n";
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case '2':
|
||||||
|
// if ($model->analyzeData()) {
|
||||||
|
// echo "\nDonnées analysées avec succès!\n";
|
||||||
|
// } else {
|
||||||
|
// echo "Erreur lors de l'analyse des données.\n";
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case '3':
|
||||||
|
// // affichage des statistiques, etc...
|
||||||
|
|
||||||
|
// $stats = $model->getStatistics();
|
||||||
|
// echo "\nStatistiques de Fréquence Cardiaque:\n";
|
||||||
|
// echo "Moyenne: {$stats['mean']}\n";
|
||||||
|
// echo "Maximum: {$stats['max']}\n";
|
||||||
|
// echo "Minimum: {$stats['min']}\n";
|
||||||
|
// echo "Variance: {$stats['variance']}\n";
|
||||||
|
// echo "Écart-type: {$stats['standardDeviation']}\n";
|
||||||
|
// case '10':
|
||||||
|
|
||||||
|
|
||||||
|
gérer une activité :
|
||||||
|
echo "2. Analyser la fréquence cardiaque\n";
|
||||||
|
echo "4. Analyser les données GPS\n";
|
||||||
|
echo "5. Détection d'anomalies\n";
|
||||||
|
echo "6. Consulter les alertes de santé\n";
|
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
namespace Database;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
class Connection extends \PDO {
|
||||||
|
|
||||||
|
private $stmt;
|
||||||
|
public function __construct(string $dsn) {
|
||||||
|
// $dsn = "pgsql:host=$this->host;port=$this->port;dbname=$this->database;user=$this->username;password=$this->password";
|
||||||
|
// This should be remove or set to just use a debug
|
||||||
|
try {
|
||||||
|
parent::__construct($dsn);
|
||||||
|
echo "Successfully connected to the database";
|
||||||
|
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
// should be a more accurate exception
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
echo("Error connecting to the database: " . $e->getMessage());
|
||||||
|
// do something ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** * @param string $query
|
||||||
|
* @param array $parameters *
|
||||||
|
* @return bool Returns `true` on success, `false` otherwise
|
||||||
|
*/
|
||||||
|
public function executeQuery(string $query, array $parameters = []) : bool{
|
||||||
|
|
||||||
|
$this->stmt = parent::prepare($query);
|
||||||
|
|
||||||
|
foreach ($parameters as $name => $value) {
|
||||||
|
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->stmt->execute();
|
||||||
|
|
||||||
|
}
|
||||||
|
public function executeWithErrorHandling(string $query,array $params = []) {
|
||||||
|
try {
|
||||||
|
$this->beginTransaction();
|
||||||
|
$this->executeQuery($query,$params);
|
||||||
|
$this->commit();
|
||||||
|
return $this->getResults();
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
$this->rollBack();
|
||||||
|
throw new \Exception('Unexpected error on database client: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResults() : array {
|
||||||
|
return $this->stmt->fetchall(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,3 @@
|
|||||||
|
la gateway ne gère pas les erreurs => elle manipule que notre sql
|
||||||
|
|
||||||
|
faire des singleton en web n'ont on aucun interet étant donné que tout est suprimé
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Service;
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
namespace Service;
|
||||||
|
/**
|
||||||
|
* Interface IAuthService
|
||||||
|
* Adding more methods here may violate the Single Responsibility Principle (SRP).
|
||||||
|
* It's recommended to keep this interface focused on authentication-related functionality.
|
||||||
|
*/
|
||||||
|
interface IAuthService {
|
||||||
|
/**
|
||||||
|
* Authenticate a user.
|
||||||
|
*
|
||||||
|
* @param string $username The username of the user.
|
||||||
|
* @param string $password The password of the user.
|
||||||
|
*
|
||||||
|
* @return bool True if authentication is successful, false otherwise.
|
||||||
|
*/
|
||||||
|
public function login(string $username, string $password): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a new user.
|
||||||
|
*
|
||||||
|
* @param string $username The username of the new user.
|
||||||
|
* @param string $password The password of the new user.
|
||||||
|
* @param string $data other data {undefined} for the moment.
|
||||||
|
*
|
||||||
|
* @return bool True if registration is successful, false otherwise.
|
||||||
|
*/
|
||||||
|
public function register(string $username, string $password, ...$data): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout the currently authenticated user.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function logoutUser(): void;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Repository;
|
||||||
|
use Model\IGenericRepository;
|
||||||
|
# garant de la donné
|
||||||
|
# il permet l'accèes au donnée (gateway & service)
|
||||||
|
|
||||||
|
// class UserRespository implements IGenericRepository{
|
||||||
|
// public function __construct(private UserService $userService,
|
||||||
|
// private UserDao $userDao)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
namespace Manager;
|
||||||
|
class DataManager {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
class Activity {
|
||||||
|
// Constructeur
|
||||||
|
public function __construct(
|
||||||
|
private int $ID_Activite,
|
||||||
|
private string $name,
|
||||||
|
private ?string $description = null,
|
||||||
|
private $Type,
|
||||||
|
private $Date,
|
||||||
|
private $Heure_de_debut,
|
||||||
|
private $Heure_de_fin,
|
||||||
|
private $Effort_Ressenti,
|
||||||
|
private $Variabilite,
|
||||||
|
private $Variance,
|
||||||
|
private $Ecart_type,
|
||||||
|
private $Moyenne,
|
||||||
|
private $Maximum,
|
||||||
|
private $Minimum,
|
||||||
|
private $Temperature_moyenne
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class DataSources {
|
||||||
|
public function __construct(
|
||||||
|
private int $id,
|
||||||
|
private string $modele,
|
||||||
|
private string $nom,
|
||||||
|
private int $precision,
|
||||||
|
private \DateTime $Date_dernière_utilisation
|
||||||
|
) {}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
// Data Class
|
||||||
|
class HeartRateData {
|
||||||
|
public function __construct(
|
||||||
|
private int $id,
|
||||||
|
private DateTime $timestamp,
|
||||||
|
private int $heartRate,
|
||||||
|
private Location $location,
|
||||||
|
private Activity $activity
|
||||||
|
) {}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
class HeartRateData {
|
||||||
|
public function __construct(
|
||||||
|
private int $dataId,
|
||||||
|
private DateTime $timestamp,
|
||||||
|
private int $heartRate,
|
||||||
|
private Location $location,
|
||||||
|
private Activity $activity
|
||||||
|
) {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
class HeartRateZone {
|
||||||
|
public function __construct(
|
||||||
|
private string $zoneName,
|
||||||
|
private int $minRate,
|
||||||
|
private int $maxRate
|
||||||
|
) {}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
// possibility
|
||||||
|
// $this->coords = [
|
||||||
|
// 'latitude' => $latitude,
|
||||||
|
// 'longitude' => $longitude,
|
||||||
|
// 'altitude' => $altitude
|
||||||
|
// ];
|
||||||
|
class Location {
|
||||||
|
public function __construct(
|
||||||
|
private float $latitude,
|
||||||
|
private float $longitude,
|
||||||
|
private float $altitude,
|
||||||
|
private DateTime $timestamp
|
||||||
|
) {}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
use DataSources;
|
||||||
|
|
||||||
|
// Data Class
|
||||||
|
class Montre extends DataSources{
|
||||||
|
public function __construct(
|
||||||
|
private int $id,
|
||||||
|
private string $modele,
|
||||||
|
private string $nom,
|
||||||
|
private int $precision,
|
||||||
|
private \DateTime $Date_dernière_utilisation
|
||||||
|
) {}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
// Data Class
|
||||||
|
|
||||||
|
class User{
|
||||||
|
public function __construct(
|
||||||
|
private int $id,
|
||||||
|
private string $nom,
|
||||||
|
private string $prenom,
|
||||||
|
private string $email,
|
||||||
|
private string $motDePasse,
|
||||||
|
private Role $role,
|
||||||
|
// rôle
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function isValidPassword(string $password){
|
||||||
|
// not implemented
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public function __toString() {
|
||||||
|
return "User [ID: {$this->id}, Nom: {$this->nom}, Prénom: {$this->prenom}, Email: {$this->email}, Rôle: {$this->role}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
class Role {
|
||||||
|
private string $name;
|
||||||
|
|
||||||
|
public function __construct(string $name) {
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): string {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString(): string {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,2 @@
|
|||||||
|
c'est le modèle qui valid les donné de la session_startil créer de new var
|
||||||
|
et c'est utilisé par la suite
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
interface IActivityRepository {
|
||||||
|
public function getHeartRateDataByUserId(int $userId): array;
|
||||||
|
public function getActivityByUserID(int $userId):array;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
interface IGenericRepository
|
||||||
|
{
|
||||||
|
public function getItemById();
|
||||||
|
public function GetNbItems(): int;
|
||||||
|
public function GetItems(int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array;
|
||||||
|
public function GetItemsByName(string $substring, int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array;
|
||||||
|
public function GetItemByName(string $substring, int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array;
|
||||||
|
public function UpdateItem($oldItem, $newItem);
|
||||||
|
public function AddItem($item);
|
||||||
|
public function DeleteItem($item): bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
interface IUserRepository {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace Stub;
|
||||||
|
class ActivityManager {
|
||||||
|
private IActivityRepository $activityRepo;
|
||||||
|
public function __construct(){}
|
||||||
|
|
||||||
|
public function visualizeGeneralHeartRateAnalysis() {
|
||||||
|
|
||||||
|
$data = $this->activityRepo->getHeartRateDataByUserId($userId);
|
||||||
|
|
||||||
|
foreach ($data as $entry) {
|
||||||
|
echo "Time: " . $entry['time'] . " - Heart Rate: " . $entry['rate'] . " BPM<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,19 @@
|
|||||||
|
<!-- IDataManager is a Model interfaces -->
|
||||||
|
<!-- It's like a DI Container -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
namespace Stub;
|
||||||
|
use Manager\DataManager;
|
||||||
|
class StubData extends DataManager{
|
||||||
|
public $userMgr;
|
||||||
|
public $activityMgr;
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
$userMgr = new UserManager();
|
||||||
|
$activityMgr = new ActivityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
namespace Stub;
|
||||||
|
use Manager\IGenericDataManager;
|
||||||
|
use Service\IAuthService;
|
||||||
|
use Utils\Validation;
|
||||||
|
// c'est le modéle
|
||||||
|
class UserManager {
|
||||||
|
private IAuthService $authService;
|
||||||
|
public function __construct(){}
|
||||||
|
|
||||||
|
public function login($loginUser,$passwordUser): bool{
|
||||||
|
if(!Validation::val_string($passwordUser) || !Validation::val_string($loginUser)) throw new \Exception(" some wrong with cred !!!!!");
|
||||||
|
if($this->authService->login($loginUser,$passwordUser)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resgister($loginUser,$passwordUser): bool{
|
||||||
|
if(!Validation::val_string($passwordUser) || !Validation::val_string($loginUser)) throw new \Exception(" some wrong with cred !!!!!");
|
||||||
|
if($this->authService->register($loginUser,$passwordUser)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deconnecter():bool{
|
||||||
|
try {
|
||||||
|
$this->authService->logoutUser();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
namespace Stub;
|
||||||
|
use Model\Activity;
|
||||||
|
use Model\IGenericRepository;
|
||||||
|
use Model\IActivityRepository;
|
||||||
|
class ActivityRepository implements IActivityRepository, IGenericRepository
|
||||||
|
{
|
||||||
|
public array $Activities = [];
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Ajout de 5 activités pour l'exemple
|
||||||
|
$this->Activities[] = new Activity(1, "Course", "Course à pied", "Sport", "2023-10-16", "08:00", "09:00", 5, 5, 5, 2, 50, 100, 10, 25);
|
||||||
|
$this->Activities[] = new Activity(2, "Natation", "Natation en piscine", "Sport", "2023-10-17", "10:00", "11:00", 4, 5, 5, 2, 55, 95, 20, 24);
|
||||||
|
$this->Activities[] = new Activity(3, "Vélo", "Vélo en montagne", "Sport", "2023-10-18", "14:00", "15:30", 6, 4, 4, 2, 45, 90, 15, 23);
|
||||||
|
$this->Activities[] = new Activity(4, "Marche", "Marche en forêt", "Loisir", "2023-10-19", "11:00", "12:00", 3, 4, 4, 2, 60, 85, 40, 22);
|
||||||
|
$this->Activities[] = new Activity(5, "Yoga", "Séance de yoga", "Sport", "2023-10-20", "16:00", "17:00", 2, 3, 3, 1, 70, 80, 65, 21);
|
||||||
|
}
|
||||||
|
public function getHeartRateDataByUserId(int $userId): array
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
public function getItemById(int $id): ?Activity {
|
||||||
|
foreach ($this->Activities as $activity) {
|
||||||
|
if ($activity->ID_Activite === $id) {
|
||||||
|
return $activity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetNbItems(): int {
|
||||||
|
return count($this->Activities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetItems(int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array {
|
||||||
|
return array_slice($this->Activities, $index, $count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetItemsByName(string $substring, int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array {
|
||||||
|
$filteredActivities = array_filter($this->Activities, function ($activity) use ($substring) {
|
||||||
|
return strpos(strtolower($activity->name), strtolower($substring)) !== false;
|
||||||
|
});
|
||||||
|
return array_slice($filteredActivities, $index, $count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetItemByName(string $substring, int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array {
|
||||||
|
return $this->GetItemsByName($substring, $index, $count, $orderingPropertyName, $descending)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function UpdateItem(Activity $oldItem, Activity $newItem): void {
|
||||||
|
$index = array_search($oldItem, $this->Activities);
|
||||||
|
if ($index !== false) {
|
||||||
|
$this->Activities[$index] = $newItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function AddItem(Activity $item): void {
|
||||||
|
$this->Activities[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DeleteItem(Activity $item): bool {
|
||||||
|
$index = array_search($item, $this->Activities);
|
||||||
|
if ($index !== false) {
|
||||||
|
unset($this->Activities[$index]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stub;
|
||||||
|
|
||||||
|
use Model\IGenericRepository;
|
||||||
|
use Model\IUserRepository;
|
||||||
|
use Model\Role;
|
||||||
|
use Model\User;
|
||||||
|
|
||||||
|
class UserRepository implements IGenericRepository,IUserRepository {
|
||||||
|
private array $users = [];
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
// Ajout de 5 utilisateurs pour l'exemple
|
||||||
|
$this->users[] = new User(1, "Doe", "John", "john.doe@example.com", "password123", new Role("Coach"));
|
||||||
|
$this->users[] = new User(2, "Smith", "Jane", "jane.smith@example.com", "secure456", new Role("User"));
|
||||||
|
$this->users[] = new User(3, "Martin", "Paul", "paul.martin@example.com", "super789", new Role("Coach"));
|
||||||
|
$this->users[] = new User(4, "Brown", "Anna", "anna.brown@example.com", "test000", new Role("User"));
|
||||||
|
$this->users[] = new User(5, "Lee", "Bruce", "bruce.lee@example.com", "hello321", new Role("User"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getItemById(int $id): ?User {
|
||||||
|
foreach ($this->users as $user) {
|
||||||
|
if ($user->id === $id) {
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetNbItems(): int {
|
||||||
|
return count($this->users);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetItems(int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array {
|
||||||
|
// Cette méthode est un exemple simple, on ne gère pas l'ordonnancement ici
|
||||||
|
return array_slice($this->users, $index, $count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetItemsByName(string $substring, int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false): array {
|
||||||
|
$filteredUsers = array_filter($this->users, function ($user) use ($substring) {
|
||||||
|
return strpos(strtolower($user->nom), strtolower($substring)) !== false || strpos(strtolower($user->prenom), strtolower($substring)) !== false;
|
||||||
|
});
|
||||||
|
return array_slice($filteredUsers, $index, $count);
|
||||||
|
}
|
||||||
|
public function GetItemByName(string $substring, int $index, int $count, ?string $orderingPropertyName = null, bool $descending = false):User {
|
||||||
|
return $this->GetItemsByName($substring, $index, $count, $orderingPropertyName, $descending)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function UpdateItem(User $oldUser, User $newUser): void {
|
||||||
|
$index = array_search($oldUser, $this->users);
|
||||||
|
if ($index !== false) {
|
||||||
|
$this->users[$index] = $newUser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function AddItem(User $user): void {
|
||||||
|
$this->users[] = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DeleteItem(User $user): bool {
|
||||||
|
$index = array_search($user, $this->users);
|
||||||
|
if ($index !== false) {
|
||||||
|
unset($this->users[$index]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
use Exception\NotImplementedException;
|
||||||
|
use Model\IUserRepository;
|
||||||
|
use Service\IAuthService;
|
||||||
|
use Utils\Validation;
|
||||||
|
|
||||||
|
class AuthService implements IAuthService {
|
||||||
|
private $userRepository;
|
||||||
|
|
||||||
|
public function __construct(UserRepository $userRepository) {
|
||||||
|
$this->userRepository = $userRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login($username, $password) {
|
||||||
|
|
||||||
|
$user = $this->userRepository->getUserByUsername($username);
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
throw new \Exception('Unable to find user with that name');
|
||||||
|
}
|
||||||
|
if ($user->isValidPassword($password)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public function register(string $username, string $password, ...$data): bool
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("register method not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logoutUser(): void
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("logout method not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAuthenticated(): bool {
|
||||||
|
|
||||||
|
if (!isset($_SESSION['token'])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!isset($_SESSION['role'])){
|
||||||
|
// get the user associate
|
||||||
|
// use middleware
|
||||||
|
throw new NotImplementedException("should be able to get the user");
|
||||||
|
}
|
||||||
|
$login=Validation::clean_string($_SESSION['login']);
|
||||||
|
$token = Validation::clean_string($_SESSION['token']);
|
||||||
|
// should check with a helper class static method how to !this.jwtHelper.isTokenExpired(token);
|
||||||
|
throw new NotImplementedException("should end this method");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 50600) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, $err);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
echo $err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
$err,
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
|
return ComposerAutoloaderInit420147ec9d8ca086267ab4a8dc6cab80::getLoader();
|
@ -0,0 +1,579 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||||
|
*
|
||||||
|
* $loader = new \Composer\Autoload\ClassLoader();
|
||||||
|
*
|
||||||
|
* // register classes with namespaces
|
||||||
|
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||||
|
* $loader->add('Symfony', __DIR__.'/framework');
|
||||||
|
*
|
||||||
|
* // activate the autoloader
|
||||||
|
* $loader->register();
|
||||||
|
*
|
||||||
|
* // to enable searching the include path (eg. for PEAR packages)
|
||||||
|
* $loader->setUseIncludePath(true);
|
||||||
|
*
|
||||||
|
* In this example, if you try to use a class in the Symfony\Component
|
||||||
|
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||||
|
* the autoloader will first look for the class under the component/
|
||||||
|
* directory, and it will then fallback to the framework/ directory if not
|
||||||
|
* found before giving up.
|
||||||
|
*
|
||||||
|
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||||
|
*
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
* @see https://www.php-fig.org/psr/psr-0/
|
||||||
|
* @see https://www.php-fig.org/psr/psr-4/
|
||||||
|
*/
|
||||||
|
class ClassLoader
|
||||||
|
{
|
||||||
|
/** @var \Closure(string):void */
|
||||||
|
private static $includeFile;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $vendorDir;
|
||||||
|
|
||||||
|
// PSR-4
|
||||||
|
/**
|
||||||
|
* @var array<string, array<string, int>>
|
||||||
|
*/
|
||||||
|
private $prefixLengthsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var array<string, list<string>>
|
||||||
|
*/
|
||||||
|
private $prefixDirsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
|
// PSR-0
|
||||||
|
/**
|
||||||
|
* List of PSR-0 prefixes
|
||||||
|
*
|
||||||
|
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, list<string>>>
|
||||||
|
*/
|
||||||
|
private $prefixesPsr0 = array();
|
||||||
|
/**
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $useIncludePath = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
private $classMap = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, bool>
|
||||||
|
*/
|
||||||
|
private $missingClasses = array();
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $apcuPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, self>
|
||||||
|
*/
|
||||||
|
private static $registeredLoaders = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|null $vendorDir
|
||||||
|
*/
|
||||||
|
public function __construct($vendorDir = null)
|
||||||
|
{
|
||||||
|
$this->vendorDir = $vendorDir;
|
||||||
|
self::initializeIncludeClosure();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<string>>
|
||||||
|
*/
|
||||||
|
public function getPrefixes()
|
||||||
|
{
|
||||||
|
if (!empty($this->prefixesPsr0)) {
|
||||||
|
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, list<string>>
|
||||||
|
*/
|
||||||
|
public function getPrefixesPsr4()
|
||||||
|
{
|
||||||
|
return $this->prefixDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function getFallbackDirs()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function getFallbackDirsPsr4()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string> Array of classname => path
|
||||||
|
*/
|
||||||
|
public function getClassMap()
|
||||||
|
{
|
||||||
|
return $this->classMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $classMap Class to filename map
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addClassMap(array $classMap)
|
||||||
|
{
|
||||||
|
if ($this->classMap) {
|
||||||
|
$this->classMap = array_merge($this->classMap, $classMap);
|
||||||
|
} else {
|
||||||
|
$this->classMap = $classMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param list<string>|string $paths The PSR-0 root directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
|
if (!$prefix) {
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->fallbackDirsPsr0
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
$this->fallbackDirsPsr0,
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$first = $prefix[0];
|
||||||
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($prepend) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
$this->prefixesPsr0[$first][$prefix],
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
|
if (!$prefix) {
|
||||||
|
// Register directories for the root namespace.
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->fallbackDirsPsr4
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
$this->fallbackDirsPsr4,
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
|
// Register directories for a new namespace.
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||||
|
} elseif ($prepend) {
|
||||||
|
// Prepend directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
$paths,
|
||||||
|
$this->prefixDirsPsr4[$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Append directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
$this->prefixDirsPsr4[$prefix],
|
||||||
|
$paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
|
* replacing any others previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param list<string>|string $paths The PSR-0 base directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr0 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
|
* replacing any others previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setPsr4($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on searching the include path for class files.
|
||||||
|
*
|
||||||
|
* @param bool $useIncludePath
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUseIncludePath($useIncludePath)
|
||||||
|
{
|
||||||
|
$this->useIncludePath = $useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used to check if the autoloader uses the include path to check
|
||||||
|
* for classes.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUseIncludePath()
|
||||||
|
{
|
||||||
|
return $this->useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns off searching the prefix and fallback directories for classes
|
||||||
|
* that have not been registered with the class map.
|
||||||
|
*
|
||||||
|
* @param bool $classMapAuthoritative
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||||
|
{
|
||||||
|
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should class lookup fail if not found in the current class map?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isClassMapAuthoritative()
|
||||||
|
{
|
||||||
|
return $this->classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||||
|
*
|
||||||
|
* @param string|null $apcuPrefix
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setApcuPrefix($apcuPrefix)
|
||||||
|
{
|
||||||
|
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getApcuPrefix()
|
||||||
|
{
|
||||||
|
return $this->apcuPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register($prepend = false)
|
||||||
|
{
|
||||||
|
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||||
|
|
||||||
|
if (null === $this->vendorDir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||||
|
} else {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function unregister()
|
||||||
|
{
|
||||||
|
spl_autoload_unregister(array($this, 'loadClass'));
|
||||||
|
|
||||||
|
if (null !== $this->vendorDir) {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given class or interface.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
* @return true|null True if loaded, null otherwise
|
||||||
|
*/
|
||||||
|
public function loadClass($class)
|
||||||
|
{
|
||||||
|
if ($file = $this->findFile($class)) {
|
||||||
|
$includeFile = self::$includeFile;
|
||||||
|
$includeFile($file);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the path to the file where the class is defined.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
*
|
||||||
|
* @return string|false The path if found, false otherwise
|
||||||
|
*/
|
||||||
|
public function findFile($class)
|
||||||
|
{
|
||||||
|
// class map lookup
|
||||||
|
if (isset($this->classMap[$class])) {
|
||||||
|
return $this->classMap[$class];
|
||||||
|
}
|
||||||
|
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (null !== $this->apcuPrefix) {
|
||||||
|
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||||
|
if ($hit) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $this->findFileWithExtension($class, '.php');
|
||||||
|
|
||||||
|
// Search for Hack files if we are running on HHVM
|
||||||
|
if (false === $file && defined('HHVM_VERSION')) {
|
||||||
|
$file = $this->findFileWithExtension($class, '.hh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $this->apcuPrefix) {
|
||||||
|
apcu_add($this->apcuPrefix.$class, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === $file) {
|
||||||
|
// Remember that this class does not exist.
|
||||||
|
$this->missingClasses[$class] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||||
|
*
|
||||||
|
* @return array<string, self>
|
||||||
|
*/
|
||||||
|
public static function getRegisteredLoaders()
|
||||||
|
{
|
||||||
|
return self::$registeredLoaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $class
|
||||||
|
* @param string $ext
|
||||||
|
* @return string|false
|
||||||
|
*/
|
||||||
|
private function findFileWithExtension($class, $ext)
|
||||||
|
{
|
||||||
|
// PSR-4 lookup
|
||||||
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
|
$first = $class[0];
|
||||||
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
|
$subPath = $class;
|
||||||
|
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||||
|
$subPath = substr($subPath, 0, $lastPos);
|
||||||
|
$search = $subPath . '\\';
|
||||||
|
if (isset($this->prefixDirsPsr4[$search])) {
|
||||||
|
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||||
|
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||||
|
if (file_exists($file = $dir . $pathEnd)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-4 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 lookup
|
||||||
|
if (false !== $pos = strrpos($class, '\\')) {
|
||||||
|
// namespaced class name
|
||||||
|
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||||
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||||
|
} else {
|
||||||
|
// PEAR-like class name
|
||||||
|
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->prefixesPsr0[$first])) {
|
||||||
|
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||||
|
if (0 === strpos($class, $prefix)) {
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 include paths.
|
||||||
|
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private static function initializeIncludeClosure()
|
||||||
|
{
|
||||||
|
if (self::$includeFile !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope isolated include.
|
||||||
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
self::$includeFile = \Closure::bind(static function($file) {
|
||||||
|
include $file;
|
||||||
|
}, null, null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,359 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer;
|
||||||
|
|
||||||
|
use Composer\Autoload\ClassLoader;
|
||||||
|
use Composer\Semver\VersionParser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is copied in every Composer installed project and available to all
|
||||||
|
*
|
||||||
|
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||||
|
*
|
||||||
|
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||||
|
*
|
||||||
|
* @final
|
||||||
|
*/
|
||||||
|
class InstalledVersions
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var mixed[]|null
|
||||||
|
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||||
|
*/
|
||||||
|
private static $installed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool|null
|
||||||
|
*/
|
||||||
|
private static $canGetVendors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
private static $installedByVendor = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
* @psalm-return list<string>
|
||||||
|
*/
|
||||||
|
public static function getInstalledPackages()
|
||||||
|
{
|
||||||
|
$packages = array();
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
$packages[] = array_keys($installed['versions']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 === \count($packages)) {
|
||||||
|
return $packages[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all package names with a specific type e.g. 'library'
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return string[]
|
||||||
|
* @psalm-return list<string>
|
||||||
|
*/
|
||||||
|
public static function getInstalledPackagesByType($type)
|
||||||
|
{
|
||||||
|
$packagesByType = array();
|
||||||
|
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
foreach ($installed['versions'] as $name => $package) {
|
||||||
|
if (isset($package['type']) && $package['type'] === $type) {
|
||||||
|
$packagesByType[] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $packagesByType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given package is installed
|
||||||
|
*
|
||||||
|
* This also returns true if the package name is provided or replaced by another package
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @param bool $includeDevRequirements
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (isset($installed['versions'][$packageName])) {
|
||||||
|
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given package satisfies a version constraint
|
||||||
|
*
|
||||||
|
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||||
|
*
|
||||||
|
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||||
|
*
|
||||||
|
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||||
|
* @param string $packageName
|
||||||
|
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||||
|
{
|
||||||
|
$constraint = $parser->parseConstraints((string) $constraint);
|
||||||
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||||
|
|
||||||
|
return $provided->matches($constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||||
|
*
|
||||||
|
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||||
|
* whether a given version of a package is installed, and not just whether it exists
|
||||||
|
*
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string Version constraint usable with composer/semver
|
||||||
|
*/
|
||||||
|
public static function getVersionRanges($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ranges = array();
|
||||||
|
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||||
|
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||||
|
}
|
||||||
|
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||||
|
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' || ', $ranges);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||||
|
*/
|
||||||
|
public static function getVersion($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||||
|
*/
|
||||||
|
public static function getPrettyVersion($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['pretty_version'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||||
|
*/
|
||||||
|
public static function getReference($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed['versions'][$packageName]['reference'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $packageName
|
||||||
|
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||||
|
*/
|
||||||
|
public static function getInstallPath($packageName)
|
||||||
|
{
|
||||||
|
foreach (self::getInstalled() as $installed) {
|
||||||
|
if (!isset($installed['versions'][$packageName])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||||
|
*/
|
||||||
|
public static function getRootPackage()
|
||||||
|
{
|
||||||
|
$installed = self::getInstalled();
|
||||||
|
|
||||||
|
return $installed[0]['root'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw installed.php data for custom implementations
|
||||||
|
*
|
||||||
|
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||||
|
*/
|
||||||
|
public static function getRawData()
|
||||||
|
{
|
||||||
|
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
if (null === self::$installed) {
|
||||||
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
|
self::$installed = include __DIR__ . '/installed.php';
|
||||||
|
} else {
|
||||||
|
self::$installed = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
public static function getAllRawData()
|
||||||
|
{
|
||||||
|
return self::getInstalled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lets you reload the static array from another file
|
||||||
|
*
|
||||||
|
* This is only useful for complex integrations in which a project needs to use
|
||||||
|
* this class but then also needs to execute another project's autoloader in process,
|
||||||
|
* and wants to ensure both projects have access to their version of installed.php.
|
||||||
|
*
|
||||||
|
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||||
|
* the data it needs from this class, then call reload() with
|
||||||
|
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||||
|
* the project in which it runs can then also use this class safely, without
|
||||||
|
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||||
|
*
|
||||||
|
* @param array[] $data A vendor/composer/installed.php data set
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||||
|
*/
|
||||||
|
public static function reload($data)
|
||||||
|
{
|
||||||
|
self::$installed = $data;
|
||||||
|
self::$installedByVendor = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||||
|
*/
|
||||||
|
private static function getInstalled()
|
||||||
|
{
|
||||||
|
if (null === self::$canGetVendors) {
|
||||||
|
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||||
|
}
|
||||||
|
|
||||||
|
$installed = array();
|
||||||
|
|
||||||
|
if (self::$canGetVendors) {
|
||||||
|
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||||
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir];
|
||||||
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||||
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require $vendorDir.'/composer/installed.php';
|
||||||
|
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||||
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
|
self::$installed = $installed[count($installed) - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === self::$installed) {
|
||||||
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
|
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||||
|
$required = require __DIR__ . '/installed.php';
|
||||||
|
self::$installed = $required;
|
||||||
|
} else {
|
||||||
|
self::$installed = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::$installed !== array()) {
|
||||||
|
$installed[] = self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $installed;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_classmap.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||||
|
);
|
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_files.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
||||||
|
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||||
|
);
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_namespaces.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
);
|
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_psr4.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'Utils\\' => array($baseDir . '/src/utils'),
|
||||||
|
'Twig\\' => array($vendorDir . '/twig/twig/src'),
|
||||||
|
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
|
||||||
|
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
||||||
|
'Service\\' => array($baseDir . '/src/core/network/service'),
|
||||||
|
'Router\\' => array($baseDir . '/src/shared/router'),
|
||||||
|
'Response\\' => array($baseDir . '/src/shared/response'),
|
||||||
|
'Request\\' => array($baseDir . '/src/shared/request'),
|
||||||
|
'Repository\\' => array($baseDir . '/src/core/repository'),
|
||||||
|
'Core\\' => array($baseDir . '/src/core'),
|
||||||
|
'Controller\\' => array($baseDir . '/src/controller'),
|
||||||
|
'App\\' => array($baseDir . '/src'),
|
||||||
|
);
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
|
class ComposerAutoloaderInit420147ec9d8ca086267ab4a8dc6cab80
|
||||||
|
{
|
||||||
|
private static $loader;
|
||||||
|
|
||||||
|
public static function loadClassLoader($class)
|
||||||
|
{
|
||||||
|
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||||
|
require __DIR__ . '/ClassLoader.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Composer\Autoload\ClassLoader
|
||||||
|
*/
|
||||||
|
public static function getLoader()
|
||||||
|
{
|
||||||
|
if (null !== self::$loader) {
|
||||||
|
return self::$loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
require __DIR__ . '/platform_check.php';
|
||||||
|
|
||||||
|
spl_autoload_register(array('ComposerAutoloaderInit420147ec9d8ca086267ab4a8dc6cab80', 'loadClassLoader'), true, true);
|
||||||
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
|
spl_autoload_unregister(array('ComposerAutoloaderInit420147ec9d8ca086267ab4a8dc6cab80', 'loadClassLoader'));
|
||||||
|
|
||||||
|
require __DIR__ . '/autoload_static.php';
|
||||||
|
call_user_func(\Composer\Autoload\ComposerStaticInit420147ec9d8ca086267ab4a8dc6cab80::getInitializer($loader));
|
||||||
|
|
||||||
|
$loader->register(true);
|
||||||
|
|
||||||
|
$filesToLoad = \Composer\Autoload\ComposerStaticInit420147ec9d8ca086267ab4a8dc6cab80::$files;
|
||||||
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
}, null, null);
|
||||||
|
foreach ($filesToLoad as $fileIdentifier => $file) {
|
||||||
|
$requireFile($fileIdentifier, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $loader;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_static.php @generated by Composer
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
class ComposerStaticInit420147ec9d8ca086267ab4a8dc6cab80
|
||||||
|
{
|
||||||
|
public static $files = array (
|
||||||
|
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||||
|
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $prefixLengthsPsr4 = array (
|
||||||
|
'U' =>
|
||||||
|
array (
|
||||||
|
'Utils\\' => 6,
|
||||||
|
),
|
||||||
|
'T' =>
|
||||||
|
array (
|
||||||
|
'Twig\\' => 5,
|
||||||
|
),
|
||||||
|
'S' =>
|
||||||
|
array (
|
||||||
|
'Symfony\\Polyfill\\Mbstring\\' => 26,
|
||||||
|
'Symfony\\Polyfill\\Ctype\\' => 23,
|
||||||
|
'Service\\' => 8,
|
||||||
|
),
|
||||||
|
'R' =>
|
||||||
|
array (
|
||||||
|
'Router\\' => 7,
|
||||||
|
'Response\\' => 9,
|
||||||
|
'Request\\' => 8,
|
||||||
|
'Repository\\' => 11,
|
||||||
|
),
|
||||||
|
'C' =>
|
||||||
|
array (
|
||||||
|
'Core\\' => 5,
|
||||||
|
'Controller\\' => 11,
|
||||||
|
),
|
||||||
|
'A' =>
|
||||||
|
array (
|
||||||
|
'App\\' => 4,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $prefixDirsPsr4 = array (
|
||||||
|
'Utils\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/utils',
|
||||||
|
),
|
||||||
|
'Twig\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/..' . '/twig/twig/src',
|
||||||
|
),
|
||||||
|
'Symfony\\Polyfill\\Mbstring\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
|
||||||
|
),
|
||||||
|
'Symfony\\Polyfill\\Ctype\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
|
||||||
|
),
|
||||||
|
'Service\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/core/network/service',
|
||||||
|
),
|
||||||
|
'Router\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/shared/router',
|
||||||
|
),
|
||||||
|
'Response\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/shared/response',
|
||||||
|
),
|
||||||
|
'Request\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/shared/request',
|
||||||
|
),
|
||||||
|
'Repository\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/core/repository',
|
||||||
|
),
|
||||||
|
'Core\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/core',
|
||||||
|
),
|
||||||
|
'Controller\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src/controller',
|
||||||
|
),
|
||||||
|
'App\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/src',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $classMap = array (
|
||||||
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
public static function getInitializer(ClassLoader $loader)
|
||||||
|
{
|
||||||
|
return \Closure::bind(function () use ($loader) {
|
||||||
|
$loader->prefixLengthsPsr4 = ComposerStaticInit420147ec9d8ca086267ab4a8dc6cab80::$prefixLengthsPsr4;
|
||||||
|
$loader->prefixDirsPsr4 = ComposerStaticInit420147ec9d8ca086267ab4a8dc6cab80::$prefixDirsPsr4;
|
||||||
|
$loader->classMap = ComposerStaticInit420147ec9d8ca086267ab4a8dc6cab80::$classMap;
|
||||||
|
|
||||||
|
}, null, ClassLoader::class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,251 @@
|
|||||||
|
{
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-ctype",
|
||||||
|
"version": "v1.28.0",
|
||||||
|
"version_normalized": "1.28.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||||
|
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
|
||||||
|
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-ctype": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-ctype": "For best performance"
|
||||||
|
},
|
||||||
|
"time": "2023-01-26T09:26:14+00:00",
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.28-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Ctype\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Gert de Pagter",
|
||||||
|
"email": "BackEndTea@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for ctype functions",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"ctype",
|
||||||
|
"polyfill",
|
||||||
|
"portable"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"install-path": "../symfony/polyfill-ctype"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-mbstring",
|
||||||
|
"version": "v1.28.0",
|
||||||
|
"version_normalized": "1.28.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||||
|
"reference": "42292d99c55abe617799667f454222c54c60e229"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229",
|
||||||
|
"reference": "42292d99c55abe617799667f454222c54c60e229",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-mbstring": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "For best performance"
|
||||||
|
},
|
||||||
|
"time": "2023-07-28T09:04:16+00:00",
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "1.28-dev"
|
||||||
|
},
|
||||||
|
"thanks": {
|
||||||
|
"name": "symfony/polyfill",
|
||||||
|
"url": "https://github.com/symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for the Mbstring extension",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"mbstring",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"install-path": "../symfony/polyfill-mbstring"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "twig/twig",
|
||||||
|
"version": "v3.7.1",
|
||||||
|
"version_normalized": "3.7.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
|
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||||
|
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2.5",
|
||||||
|
"symfony/polyfill-ctype": "^1.8",
|
||||||
|
"symfony/polyfill-mbstring": "^1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"psr/container": "^1.0|^2.0",
|
||||||
|
"symfony/phpunit-bridge": "^5.4.9|^6.3"
|
||||||
|
},
|
||||||
|
"time": "2023-08-28T11:09:02+00:00",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Twig\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com",
|
||||||
|
"homepage": "http://fabien.potencier.org",
|
||||||
|
"role": "Lead Developer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Twig Team",
|
||||||
|
"role": "Contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Armin Ronacher",
|
||||||
|
"email": "armin.ronacher@active-4.com",
|
||||||
|
"role": "Project Founder"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
||||||
|
"homepage": "https://twig.symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"templating"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
|
"source": "https://github.com/twigphp/Twig/tree/v3.7.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"install-path": "../twig/twig"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"dev-package-names": []
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php return array(
|
||||||
|
'root' => array(
|
||||||
|
'name' => 'hearttrack/package',
|
||||||
|
'pretty_version' => 'dev-master',
|
||||||
|
'version' => 'dev-master',
|
||||||
|
'reference' => '3d31abede6b4ca97fe664ffedb59608d3a6f0e7e',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../../',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev' => true,
|
||||||
|
),
|
||||||
|
'versions' => array(
|
||||||
|
'hearttrack/package' => array(
|
||||||
|
'pretty_version' => 'dev-master',
|
||||||
|
'version' => 'dev-master',
|
||||||
|
'reference' => '3d31abede6b4ca97fe664ffedb59608d3a6f0e7e',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../../',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/polyfill-ctype' => array(
|
||||||
|
'pretty_version' => 'v1.28.0',
|
||||||
|
'version' => '1.28.0.0',
|
||||||
|
'reference' => 'ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'symfony/polyfill-mbstring' => array(
|
||||||
|
'pretty_version' => 'v1.28.0',
|
||||||
|
'version' => '1.28.0.0',
|
||||||
|
'reference' => '42292d99c55abe617799667f454222c54c60e229',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'twig/twig' => array(
|
||||||
|
'pretty_version' => 'v3.7.1',
|
||||||
|
'version' => '3.7.1.0',
|
||||||
|
'reference' => 'a0ce373a0ca3bf6c64b9e3e2124aca502ba39554',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../twig/twig',
|
||||||
|
'aliases' => array(),
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// platform_check.php @generated by Composer
|
||||||
|
|
||||||
|
$issues = array();
|
||||||
|
|
||||||
|
if (!(PHP_VERSION_ID >= 70205)) {
|
||||||
|
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issues) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,232 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Polyfill\Ctype;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ctype implementation through regex.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @author Gert de Pagter <BackEndTea@gmail.com>
|
||||||
|
*/
|
||||||
|
final class Ctype
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-alnum
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_alnum($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is a letter, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-alpha
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_alpha($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-cntrl
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_cntrl($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-digit
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_digit($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-graph
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_graph($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is a lowercase letter.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-lower
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_lower($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-print
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_print($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-punct
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_punct($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-space
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_space($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is an uppercase letter.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-upper
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_upper($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
|
||||||
|
*
|
||||||
|
* @see https://php.net/ctype-xdigit
|
||||||
|
*
|
||||||
|
* @param mixed $text
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ctype_xdigit($text)
|
||||||
|
{
|
||||||
|
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
|
||||||
|
|
||||||
|
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts integers to their char versions according to normal ctype behaviour, if needed.
|
||||||
|
*
|
||||||
|
* If an integer between -128 and 255 inclusive is provided,
|
||||||
|
* it is interpreted as the ASCII value of a single character
|
||||||
|
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
|
||||||
|
* Any other integer is interpreted as a string containing the decimal digits of the integer.
|
||||||
|
*
|
||||||
|
* @param mixed $int
|
||||||
|
* @param string $function
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private static function convert_int_to_char_for_ctype($int, $function)
|
||||||
|
{
|
||||||
|
if (!\is_int($int)) {
|
||||||
|
return $int;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($int < -128 || $int > 255) {
|
||||||
|
return (string) $int;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\PHP_VERSION_ID >= 80100) {
|
||||||
|
@trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($int < 0) {
|
||||||
|
$int += 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
return \chr($int);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue