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