| Total Complexity | 8 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class CardCollection |
||
| 8 | { |
||
| 9 | private array $cards = []; |
||
| 10 | |||
| 11 | public function addCard(Card $card): void |
||
| 12 | { |
||
| 13 | $this->cards[] = $card; |
||
| 14 | } |
||
| 15 | |||
| 16 | public function drawCards(int $numberOfCards): array |
||
| 17 | { |
||
| 18 | $drawnCards = []; |
||
| 19 | for ($i = 0; $i < $numberOfCards; $i++) { |
||
| 20 | if (empty($this->cards)) { |
||
| 21 | throw new Exception('No cards left in the deck'); |
||
| 22 | } |
||
| 23 | $drawnCards[] = array_pop($this->cards); |
||
| 24 | } |
||
| 25 | return $drawnCards; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getCards(): array |
||
| 29 | { |
||
| 30 | return $this->cards; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function setCards(array $cards): void |
||
| 36 | } |
||
| 37 | |||
| 38 | public function hasCards(): bool |
||
| 39 | { |
||
| 40 | return !empty($this->cards); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function getNumberOfCards(): int |
||
| 46 | } |
||
| 47 | } |
||
| 48 |