add documentation

pull/2/head
Override-6 2 years ago
parent 7ef39298c4
commit 9ce609acab
Signed by untrusted user who does not match committer: maxime.batista
GPG Key ID: 8002CC4B4DD9ECA5

@ -3,12 +3,14 @@
class Account { class Account {
- email: String - email: String
- phoneNumber: String - phoneNumber: String
- id: int
+ setMailAddress(String) + setMailAddress(String)
+ getMailAddress(): String + getMailAddress(): String
+ getPhoneNumber(): String + getPhoneNumber(): String
+ setPhoneNumber(String) + setPhoneNumber(String)
+ getUser(): AccountUser + getUser(): AccountUser
+ getId(): int
} }
Account --> "- user" AccountUser Account --> "- user" AccountUser
@ -32,11 +34,12 @@ class AccountUser {
AccountUser ..|> User AccountUser ..|> User
class Member { class Member {
getUser(): User - userId: int
getRole(): MemberRole
+ getUserId(): int
+ getRole(): MemberRole
} }
Member --> "- user" User
Member --> "- role" MemberRole Member --> "- role" MemberRole
enum MemberRole { enum MemberRole {
@ -60,9 +63,9 @@ Team --> "- mainColor" Color
Team --> "- secondaryColor" Color Team --> "- secondaryColor" Color
class Color { class Color {
value: int - value: int
getValue(): int + getValue(): int
} }
@enduml @enduml

@ -4,25 +4,53 @@ namespace App\Data;
use http\Exception\InvalidArgumentException; use http\Exception\InvalidArgumentException;
const PHONE_NUMBER_REGEXP = "\\+[0-9]+";
/**
* Base class of a user account.
* Contains the private information that we don't want
* to share to other users, or non-needed public information
*/
class Account { class Account {
/**
* @var string $email account's mail address
*/
private string $email; private string $email;
/**
* @var string account's phone number.
* its format is specified by the {@link PHONE_NUMBER_REGEXP} constant
*
*/
private string $phoneNumber; private string $phoneNumber;
/**
* @var AccountUser account's public and shared information
*/
private AccountUser $user; private AccountUser $user;
/**
* @var array account's teams
*/
private array $teams; private array $teams;
/**
* @var int account's unique identifier
*/
private int $id;
/** /**
* @param string $email * @param string $email
* @param string $phoneNumber * @param string $phoneNumber
* @param AccountUser $user * @param AccountUser $user
*/ */
public function __construct(string $email, string $phoneNumber, AccountUser $user, array $teams) { public function __construct(string $email, string $phoneNumber, AccountUser $user, array $teams, int $id) {
$this->email = $email; $this->email = $email;
$this->phoneNumber = $phoneNumber; $this->phoneNumber = $phoneNumber;
$this->user = $user; $this->user = $user;
$this->teams = $teams; $this->teams = $teams;
$this->id = $id;
} }
/** /**
* @return string * @return string
*/ */
@ -51,11 +79,21 @@ class Account {
* @param string $phoneNumber * @param string $phoneNumber
*/ */
public function setPhoneNumber(string $phoneNumber): void { public function setPhoneNumber(string $phoneNumber): void {
if (!filter_var($phoneNumber, FILTER_VALIDATE_REGEXP, "\\+[0-9]+")) { if (!filter_var($phoneNumber, FILTER_VALIDATE_REGEXP, PHONE_NUMBER_REGEXP)) {
throw new InvalidArgumentException("Invalid phone number"); throw new InvalidArgumentException("Invalid phone number");
} }
$this->phoneNumber = $phoneNumber; $this->phoneNumber = $phoneNumber;
} }
public function getId(): int {
return $this->id;
}
public function getTeams(): array {
return $this->teams;
}
public function getUser(): AccountUser {
return $this->user;
}
} }

@ -4,12 +4,14 @@ namespace App\Data;
use http\Url; use http\Url;
/**
* This class implements the User and
*/
class AccountUser implements User { class AccountUser implements User {
private string $name; private string $name;
private Url $profilePicture; private Url $profilePicture;
private int $age; private int $age;
private array $teams; private array $teams;
private int $id;
/** /**
* @param string $name * @param string $name
@ -52,8 +54,4 @@ class AccountUser implements User {
return $this->teams; return $this->teams;
} }
public function getId(): int {
return $this->id;
}
} }

@ -2,15 +2,25 @@
namespace App\Data; namespace App\Data;
/**
* information about a team member
*/
class Member { class Member {
/**
* @var int The member's user id
*/
private int $userId; private int $userId;
private int $role;
/**
* @var MemberRole the member's role
*/
private MemberRole $role;
/** /**
* @param int $userId * @param int $userId
* @param int $role * @param MemberRole $role
*/ */
public function __construct(int $userId, int $role) { public function __construct(int $userId, MemberRole $role) {
$this->userId = $userId; $this->userId = $userId;
$this->role = $role; $this->role = $role;
} }
@ -23,9 +33,9 @@ class Member {
} }
/** /**
* @return int * @return MemberRole
*/ */
public function getRole(): int { public function getRole(): MemberRole {
return $this->role; return $this->role;
} }

@ -5,6 +5,11 @@ namespace App\Data;
use http\Exception\InvalidArgumentException; use http\Exception\InvalidArgumentException;
/**
* Enumeration class workaround
* As there is no enumerations in php 7.4, this class
* encapsulates an integer value and use it as an enumeration discriminant
*/
final class MemberRole { final class MemberRole {
private const ROLE_PLAYER = 0; private const ROLE_PLAYER = 0;
private const ROLE_COACH = 1; private const ROLE_COACH = 1;

@ -2,6 +2,8 @@
namespace App\Data; namespace App\Data;
use http\Url;
class Team { class Team {
private string $name; private string $name;
private Url $picture; private Url $picture;

@ -4,10 +4,24 @@ namespace App\Data;
use http\Url; use http\Url;
/**
* Public information about a user
*/
interface User { interface User {
/**
* @return string the user's name
*/
public function getName(): string; public function getName(): string;
/**
* @return Url The user's profile picture image URL
*/
public function getProfilePicture(): Url; public function getProfilePicture(): Url;
/**
* @return int The user's age
*/
public function getAge(): int; public function getAge(): int;
} }
Loading…
Cancel
Save