| Total Complexity | 7 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 11 | class Player extends CardHand |
||
| 12 | { |
||
| 13 | protected int $handValue; |
||
| 14 | protected bool $isBust; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * checkIsBust. |
||
| 18 | */ |
||
| 19 | 16 | protected function checkIsBust(): void |
|
| 20 | { |
||
| 21 | 16 | ($this->handValue > 21) ? $this->isBust = true : $this->isBust = false; |
|
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * calculateHandValue. |
||
| 26 | */ |
||
| 27 | 16 | protected function calculateHandValue(): void |
|
| 28 | { |
||
| 29 | 16 | $lowValue = $this->getBlackJackValue(); |
|
| 30 | 16 | $highValue = $this->getBlackJackValueAceHigh(); |
|
| 31 | |||
| 32 | 16 | $this->handValue = ($highValue > 21) ? $lowValue : $highValue; |
|
| 33 | |||
| 34 | 16 | $this->checkIsBust(); |
|
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * isBust. |
||
| 39 | */ |
||
| 40 | 7 | public function isBust(): bool |
|
| 41 | { |
||
| 42 | 7 | return $this->isBust; |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * getHandValue. |
||
| 47 | */ |
||
| 48 | 10 | public function getHandValue(): int |
|
| 49 | { |
||
| 50 | 10 | return $this->handValue; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * addCard. |
||
| 55 | */ |
||
| 56 | 16 | public function addCard(Card $card): void |
|
| 61 | } |
||
| 62 | } |
||
| 63 |