| Total Complexity | 4 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 70% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | trait WithGames |
||
| 19 | { |
||
| 20 | /** @var GameContainer List of games */ |
||
| 21 | protected GameContainer $games; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Add a child container for games |
||
| 25 | * |
||
| 26 | * @param GameContainer $container |
||
| 27 | * |
||
| 28 | * @return WithGamesInterface |
||
| 29 | * @throws \Exception |
||
| 30 | */ |
||
| 31 | 70 | public function addGameContainer(GameContainer $container) : WithGamesInterface { |
|
| 32 | 70 | $this->games->addChild($container); |
|
| 33 | 70 | return $this; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Get all tournament games |
||
| 38 | * |
||
| 39 | * @return Game[] |
||
| 40 | */ |
||
| 41 | 53 | public function getGames() : array { |
|
| 42 | 53 | return $this->games->get(); |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Get the container for games |
||
| 47 | * |
||
| 48 | * @return GameContainer |
||
| 49 | */ |
||
| 50 | 74 | public function getGameContainer() : GameContainer { |
|
| 51 | 74 | return $this->games; |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Sets a new autoincrement value (start) for the generated games |
||
| 56 | * |
||
| 57 | * @param int $id Id - probably from the database |
||
| 58 | * |
||
| 59 | * @warning Do this on the top-level hierarchy element (Tournament class) or else, it might be reset later |
||
| 60 | * |
||
| 61 | * @post Propagates the value to all child hierarchy objects |
||
| 62 | * |
||
| 63 | * @see GameContainer::setAutoIncrement() |
||
| 64 | * |
||
| 65 | * @return WithGamesInterface |
||
| 66 | * @since 0.5 |
||
| 67 | */ |
||
| 68 | public function setGameAutoincrementId(int $id) : WithGamesInterface { |
||
| 71 | } |
||
| 72 | } |