From 1ac81d7349a2dbad33459bf6a4e76de8f701d103 Mon Sep 17 00:00:00 2001 From: "mael.daim" Date: Mon, 8 Jan 2024 23:01:14 +0100 Subject: [PATCH] removed unsed class Color --- front/model/team/Team.ts | 8 ++--- front/views/TeamPanel.tsx | 6 ++-- src/App/Views/edit_team.html.twig | 4 +-- src/Core/Data/Color.php | 50 ------------------------------- src/Core/Data/TeamInfo.php | 14 ++++----- src/Core/Gateway/TeamGateway.php | 5 ++-- src/Core/Model/TeamModel.php | 1 - 7 files changed, 16 insertions(+), 72 deletions(-) delete mode 100755 src/Core/Data/Color.php diff --git a/front/model/team/Team.ts b/front/model/team/Team.ts index 3a7f983..01a9d10 100644 --- a/front/model/team/Team.ts +++ b/front/model/team/Team.ts @@ -2,12 +2,8 @@ export interface TeamInfo { id: number name: string picture: string - mainColor: Color - secondColor: Color -} - -export interface Color { - hex: string + mainColor: string + secondColor: string } export interface Team { diff --git a/front/views/TeamPanel.tsx b/front/views/TeamPanel.tsx index 66826b0..2afcc34 100644 --- a/front/views/TeamPanel.tsx +++ b/front/views/TeamPanel.tsx @@ -1,6 +1,6 @@ import "../style/team_panel.css" import { BASE } from "../Constants" -import { Team, TeamInfo, Color, User, Member } from "../model/team/Team" +import { Team, TeamInfo, User, Member } from "../model/team/Team" export default function TeamPanel({ isCoach, @@ -53,8 +53,8 @@ function TeamDisplay({ team }: { team: TeamInfo }) { ) } -function ColorDisplay({ color }: { color: Color }) { - return
+function ColorDisplay({ color }: { color: string }) { + return
} function CoachOptions({ id }: { id: number }) { diff --git a/src/App/Views/edit_team.html.twig b/src/App/Views/edit_team.html.twig index 00eef84..409d71a 100644 --- a/src/App/Views/edit_team.html.twig +++ b/src/App/Views/edit_team.html.twig @@ -67,9 +67,9 @@ - + - +
diff --git a/src/Core/Data/Color.php b/src/Core/Data/Color.php deleted file mode 100755 index f6244cd..0000000 --- a/src/Core/Data/Color.php +++ /dev/null @@ -1,50 +0,0 @@ -hex = $value; - } - - /** - * @return string - */ - public function getValue(): string { - return $this->hex; - } - - public static function from(string $value): Color { - $color = self::tryFrom($value); - if ($color == null) { - - throw new InvalidArgumentException("The string is not an hexadecimal code"); - } - return $color; - } - - public static function tryFrom(string $value): ?Color { - if (!preg_match('/#(?:[0-9a-fA-F]{6})/', $value)) { - return null; - } - return new Color($value); - } - - public function jsonSerialize() { - return get_object_vars($this); - } - - -} diff --git a/src/Core/Data/TeamInfo.php b/src/Core/Data/TeamInfo.php index 63b6a99..0f741fe 100644 --- a/src/Core/Data/TeamInfo.php +++ b/src/Core/Data/TeamInfo.php @@ -6,17 +6,17 @@ class TeamInfo implements \JsonSerializable { private int $id; private string $name; private string $picture; - private Color $mainColor; - private Color $secondColor; + private string $mainColor; + private string $secondColor; /** * @param int $id * @param string $name * @param string $picture - * @param Color $mainColor - * @param Color $secondColor + * @param string $mainColor + * @param string $secondColor */ - public function __construct(int $id, string $name, string $picture, Color $mainColor, Color $secondColor) { + public function __construct(int $id, string $name, string $picture, string $mainColor, string $secondColor) { $this->id = $id; $this->name = $name; $this->picture = $picture; @@ -37,11 +37,11 @@ class TeamInfo implements \JsonSerializable { return $this->picture; } - public function getMainColor(): Color { + public function getMainColor(): string { return $this->mainColor; } - public function getSecondColor(): Color { + public function getSecondColor(): string { return $this->secondColor; } diff --git a/src/Core/Gateway/TeamGateway.php b/src/Core/Gateway/TeamGateway.php index 9804e6b..71df931 100644 --- a/src/Core/Gateway/TeamGateway.php +++ b/src/Core/Gateway/TeamGateway.php @@ -3,7 +3,6 @@ namespace IQBall\Core\Gateway; use IQBall\Core\Connection; -use IQBall\Core\Data\Color; use IQBall\Core\Data\TeamInfo; use PDO; @@ -47,7 +46,7 @@ class TeamGateway { "id" => [$id, PDO::PARAM_INT], ] ); - return array_map(fn($row) => new TeamInfo($row['id'], $row['name'], $row['picture'], Color::from($row['main_color']), Color::from($row['second_color'])), $result); + return array_map(fn($row) => new TeamInfo($row['id'], $row['name'], $row['picture'], $row['main_color'], $row['second_color']), $result); } /** @@ -64,7 +63,7 @@ class TeamGateway { if ($row == null) { return null; } - return new TeamInfo($row['id'], $row['name'], $row['picture'], Color::from($row['main_color']), Color::from($row['second_color'])); + return new TeamInfo($row['id'], $row['name'], $row['picture'], $row['main_color'], $row['second_color']); } /** diff --git a/src/Core/Model/TeamModel.php b/src/Core/Model/TeamModel.php index 9e2821a..9f03953 100644 --- a/src/Core/Model/TeamModel.php +++ b/src/Core/Model/TeamModel.php @@ -2,7 +2,6 @@ namespace IQBall\Core\Model; -use IQBall\Core\Data\Color; use IQBall\Core\Data\Team; use IQBall\Core\Data\TeamInfo; use IQBall\Core\Gateway\AccountGateway;