diff --git a/Documentation/models.puml b/Documentation/models.puml index 727b2e3..b88b543 100755 --- a/Documentation/models.puml +++ b/Documentation/models.puml @@ -6,51 +6,75 @@ class TacticInfo { - creationDate: string - ownerId: string - content: string - + + + __construct(id:int,name:string,creationDate:int,ownerId:int,courtType:CourtType,content:string) + getId(): int + getOwnerId(): int + getCreationTimestamp(): int + getName(): string + getContent(): string + + getCourtType() : CourtType +} + +TacticInfo -->"- courtType" CourtType + +class CourtType{ + - value : int + - COURT_PLAIN : int {static} {frozen} + - COURT_HALF : int {static} {frozen} + + - __construct(val:int) + + plain() : CourtType {static} + + half() : CourtType {static} + + name() : string + + fromName(name:string) : CourtType + + isPlain() : bool + + isHalf() : bool } +note bottom: Basically an evoluated enum + class Account { - - email: string - token: string - - name: string - - id: int - + getMailAddress(): string - + getToken(): string - + getName(): string - + getId(): int + + __construct(token:string,user:User) + + getUser() : User + + getToken() : string } +Account -->"- user" User + class Member { - - userId: int - teamId: int - role : string + + __construct(role : string) - + getUserId(): int + + getUser(): User + getTeamId(): int + getRole(): string } +note bottom: Member's role is either "Coach" or "Player" + +Member -->"- user" User class TeamInfo { - - creationDate: int - name: string - picture: string - mainColor : string - secondColor : string + + + __construct(id:int,name:string,picture:string,mainColor:string,secondColor:string) + getName(): string + getPicture(): string + getMainColor(): string + getSecondColor(): string } +note left: Both team's color are the hex code of the color + class Team { - + __construct() + + __construct(info:TeamInfo,members: Member[]) + getInfo(): TeamInfo + listMembers(): Member[] } diff --git a/Documentation/mvc/auth.puml b/Documentation/mvc/auth.puml index 8a2bb1f..d6b56fa 100644 --- a/Documentation/mvc/auth.puml +++ b/Documentation/mvc/auth.puml @@ -7,26 +7,26 @@ class AuthController { + displayLogin() : HttpResponse + login(request : array , session : MutableSessionHandle) : HttpResponse } -AuthController --> "- model" AuthModel +AuthController *-- "- model" AuthModel class AuthModel { - +__construct(gateway : AccountGateway) - + register(username : string, password : string, confirmPassword : string, email : string, failures : array): Account - + generateToken() : string - + login(email : string, password : string) + + __construct(gateway : AccountGateway) + + register(username:string, password:string, confirmPassword:string, email:string, &failures:array): ?Account + generateToken() : string + + generateToken(): string + + login(email:string, password:string, &failures:array): ?Account } -AuthModel --> "- gateway" AccountGateway - -class AccountGateway { - -con : Connection - +__construct(con : Connection) - + insertAccount(name : string, email : string, hash : string, token : string) : int - + getRowsFromMail(email : string): array - + getHash(email : string) : array - + exists(email : string) : bool - + getAccountFromMail(email : string ): Account - + getAccountFromToken(email : string ): Account +AuthModel *-- "- gateway" AccountGateway +class AccountGateway{ + + __construct(con : Connexion) + + insertAccount(name:string, email:string, token:string, hash:string, profilePicture:string): int + + getRowsFromMail(email:string): ?array + + getHash(email:string): ?string + + exists(email:string): bool + + getAccountFromMail(email:string): ?Account + + getAccountFromToken(token:string): ?Account } +AccountGateway *--"- con" Connexion + @enduml \ No newline at end of file diff --git a/Documentation/mvc/editor.puml b/Documentation/mvc/editor.puml new file mode 100644 index 0000000..d684e5b --- /dev/null +++ b/Documentation/mvc/editor.puml @@ -0,0 +1,38 @@ +@startuml +class EditorController { + +__construct (model : TacticModel) + + openEditorFor(tactic:TacticInfo): ViewHttpResponse + + createNew(): ViewHttpResponse + + openTestEditor(courtType:CourtType): ViewHttpResponse + + createNewOfKind(type:CourtType, session:SessionHandle): ViewHttpResponse + + openEditor(id:int, session:SessionHandle): ViewHttpResponse +} +EditorController *-- "- model" TacticModel + +class TacticModel { + + TACTIC_DEFAULT_NAME:int {static}{frozen} + + __construct(tactics : TacticInfoGateway) + + makeNew(name:string, ownerId:int, type:CourtType): TacticInfo + + makeNewDefault(ownerId:int, type:CourtType): ?TacticInfo + + get(id:int): ?TacticInfo + + getLast(nb:int, ownerId:int): array + + getAll(ownerId:int): ?array + + updateName(id:int, name:string, authId:int): array + + updateContent(id:int, json:string): ?ValidationFail +} + +TacticModel *-- "- tactics" TacticInfoGateway + +class TacticInfoGateway{ + + __construct(con : Connexion) + + get(id:int): ?TacticInfo + + getLast(nb:int, ownerId:int): ?array + + getAll(ownerId:int): ?array + + insert(name:string, owner:int, type:CourtType): int + + updateName(id:int, name:string): bool + + updateContent(id:int, json:string): bool +} + +TacticInfoGateway *--"- con" Connexion + +@enduml \ No newline at end of file diff --git a/Documentation/mvc/team.puml b/Documentation/mvc/team.puml index ad5e201..8762ffe 100644 --- a/Documentation/mvc/team.puml +++ b/Documentation/mvc/team.puml @@ -1,63 +1,87 @@ @startuml -class Team { - - name: string - - picture: Url - - members: array - - + __construct(name : string, picture : string, mainColor : Colo, secondColor : Color) - + getName(): string - + getPicture(): Url - + getMainColor(): Color - + getSecondColor(): Color - + listMembers(): array -} -Team --> "- mainColor" Color -Team --> "- secondColor" Color -class Color { - - value: string - - __construct(value : string) - + getValue(): string - + from(value: string): Color - + tryFrom(value : string) : ?Color -} class TeamGateway{ - -- + + __construct(con : Connexion) + insert(name : string ,picture : string, mainColor : Color, secondColor : Color) + listByName(name : string): array + + getTeamById(id:int): ?TeamInfo + + getTeamIdByName(name:string): ?int + + deleteTeam(idTeam:int): void + + editTeam(idTeam:int, newName:string, newPicture:string, newMainColor:string, newSecondColor:string) + + getAll(user:int): array } TeamGateway *--"- con" Connexion -TeamGateway ..> Color + + +class MemberGateway{ + + + __construct(con : Connexion) + + insert(idTeam:int, userId:int, role:string): void + + getMembersOfTeam(teamId:int): array + + remove(idTeam:int, idMember:int): void + + isCoach(email:string, idTeam:int): bool + + isMemberOfTeam(idTeam:int, idCurrentUser:int): bool +} + +MemberGateway *--"- con" Connexion + +class AccountGateway{ + + __construct(con : Connexion) + + insertAccount(name:string, email:string, token:string, hash:string, profilePicture:string): int + + getRowsFromMail(email:string): ?array + + getHash(email:string): ?string + + exists(email:string): bool + + getAccountFromMail(email:string): ?Account + + getAccountFromToken(token:string): ?Account +} + +AccountGateway *--"- con" Connexion class TeamModel{ - --- + + __construct(gateway : TeamGateway) + createTeam(name : string,picture : string, mainColorValue : int, secondColorValue : int, errors : array) + + addMember(mail:string, teamId:int, role:string): int + listByName(name : string ,errors : array) : ?array - + displayTeam(id : int): Team + + getTeam(idTeam:int, idCurrentUser:int): ?Team + + deleteMember(idMember:int, teamId:int): int + + deleteTeam(email:string, idTeam:int): int + + isCoach(idTeam:int, email:string): bool + + editTeam(idTeam:int, newName:string, newPicture:string, newMainColor:string, newSecondColor:string) + + getAll(user:int): array } -TeamModel *--"- gateway" TeamGateway -TeamModel ..> Team -TeamModel ..> Color +TeamModel *--"- members" MemberGateway +TeamModel *--"- teams" TeamGateway +TeamModel *--"- teams" AccountGateway + class TeamController{ - - twig : Environement - -- - + __construct( model : TeamModel, twig : Environement) - + displaySubmitTeam() : HttpResponse - + submitTeam(request : array) : HttpResponse - + displayListTeamByName(): HttpResponse - + listTeamByName(request : array) : HttpResponse - + displayTeam(id : int): HttpResponse + + __construct( model : TeamModel) + + displayCreateTeam(session:SessionHandle): ViewHttpResponse + + displayDeleteMember(session:SessionHandle): ViewHttpResponse + + submitTeam(request:array, session:SessionHandle): HttpResponse + + displayListTeamByName(session:SessionHandle): ViewHttpResponse + + listTeamByName(request:array, session:SessionHandle): HttpResponse + + deleteTeamById(id:int, session:SessionHandle): HttpResponse + + displayTeam(id:int, session:SessionHandle): ViewHttpResponse + + displayAddMember(idTeam:int, session:SessionHandle): ViewHttpResponse + + addMember(idTeam:int, request:array, session:SessionHandle): HttpResponse + + deleteMember(idTeam:int, idMember:int, session:SessionHandle): HttpResponse + + displayEditTeam(idTeam:int, session:SessionHandle): ViewHttpResponse + + editTeam(idTeam:int, request:array, session:SessionHandle): HttpResponse } TeamController *--"- model" TeamModel + + + + class Connexion { } @enduml \ No newline at end of file diff --git a/Documentation/validation.puml b/Documentation/validation.puml index f509cf4..4595a5a 100644 --- a/Documentation/validation.puml +++ b/Documentation/validation.puml @@ -1,18 +1,20 @@ @startuml abstract class Validator { - + validate(name: string, val: mixed): array + + validate(name: string, val: mixed): array {abstract} + then(other: Validator): Validator } class ComposedValidator extends Validator { - - first: Validator - - then: Validator + __construct(first: Validator, then: Validator) - validate(name: string, val: mixed): array + + validate(name: string, val: mixed): array } +ComposedValidator -->"- first" Validator +ComposedValidator -->"- then" Validator + + class SimpleFunctionValidator extends Validator { - predicate: callable - error_factory: callable @@ -28,9 +30,9 @@ class ValidationFail implements JsonSerialize { + __construct(kind: string, message: string) + getMessage(): string + getKind(): string - + jsonSerialize() - + notFound(message: string): ValidationFail + + unauthorized(message:string): ValidationFail + + error(message:string): ValidationFail } class FieldValidationFail extends ValidationFail { @@ -49,13 +51,25 @@ class Validation { + validate(val: mixed, valName: string, failures: &array, validators: Validator...): bool } +Validation ..> Validator + class Validators { - --- + nonEmpty(): Validator + shorterThan(limit: int): Validator + userString(maxLen: int): Validator - ... + + regex(regex:string, msg:string): Validator + + hex(msg:string): Validator + + name(msg:string): Validator + + nameWithSpaces(): Validator + + lenBetween(min:int, max:int): Validator + + email(msg:string): Validator + + isInteger(): Validator + + isIntInRange(min:int, max:int): Validator + + isURL(): Validator } +Validators ..> Validator + + @enduml \ No newline at end of file diff --git a/src/Core/Model/TacticModel.php b/src/Core/Model/TacticModel.php index 7057e7f..4953fb2 100644 --- a/src/Core/Model/TacticModel.php +++ b/src/Core/Model/TacticModel.php @@ -11,7 +11,6 @@ use IQBall\Core\Validation\ValidationFail; class TacticModel { public const TACTIC_DEFAULT_NAME = "Nouvelle tactique"; - private TacticInfoGateway $tactics; /** @@ -52,13 +51,6 @@ class TacticModel { return $this->tactics->get($id); } - /** - * Return the nb last tactics created - * - * @param integer $nb - * @return array> - */ - /** * Return the nb last tactics *