gateway = $gateway; } public function createTeam(string $name, string $picture, string $mainColor, string $secondColor): int { $this->gateway->insert($name, $picture, $mainColor, $secondColor); $result = $this->gateway->getIdTeamByName($name); return intval($result[0]['id']); } /** * @param string $name * @return Team[] */ public function listByName(string $name): array { $teams = []; $results = $this->gateway->listByName($name); foreach ($results as $row) { $teams[] = new Team($row['id'], $row['name'], $row['picture'], Color::from($row['mainColor']), Color::from($row['secondColor'])); } return $teams; } public function displayTeam(int $id): Team { $members = []; $result = $this->gateway->getTeamById($id)[0]; $resultMembers = $this->gateway->getMembersById($id); foreach ($resultMembers as $row) { if ($row['role'] == 'C') { $role = MemberRole::coach(); } else { $role = MemberRole::player(); } $members[] = new Member($row['id'], $role); } return new Team(intval($result['id']), $result['name'], $result['picture'], Color::from($result['mainColor']), Color::from($result['secondColor']), $members); } }