Total Complexity | 8 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class DiceHand |
||
14 | { |
||
15 | /** @var Dice[] Array holding Dice objects in the hand */ |
||
16 | private $hand = []; |
||
17 | |||
18 | /** |
||
19 | * Add a Dice object to the hand. |
||
20 | * |
||
21 | * @param Dice $die |
||
22 | */ |
||
23 | 5 | public function add(Dice $die): void |
|
24 | { |
||
25 | 5 | $this->hand[] = $die; |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * Roll all dice in the hand. |
||
30 | */ |
||
31 | 4 | public function roll(): void |
|
32 | { |
||
33 | 4 | foreach ($this->hand as $die) { |
|
34 | 4 | $die->roll(); |
|
35 | } |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get the number of dice in the hand. |
||
40 | * |
||
41 | * @return int The count of dice. |
||
42 | */ |
||
43 | 2 | public function getNumberDices(): int |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get numeric values from all dice in the hand. |
||
50 | * |
||
51 | * @return int[] |
||
52 | */ |
||
53 | 1 | public function getValues(): array |
|
54 | { |
||
55 | 1 | $values = []; |
|
56 | 1 | foreach ($this->hand as $die) { |
|
57 | 1 | $values[] = $die->getValue(); |
|
58 | } |
||
59 | 1 | return $values; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Get visual string representations from all dice in the hand. |
||
64 | * |
||
65 | * @return string[] |
||
66 | */ |
||
67 | 3 | public function getString(): array |
|
74 | } |
||
75 | } |
||
76 |