Total Complexity | 5 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class Dice |
||
13 | { |
||
14 | /** |
||
15 | * Dice constructor. |
||
16 | * |
||
17 | * Initializes the dice with no value (not rolled yet). |
||
18 | */ |
||
19 | /** @var int|null */ |
||
20 | protected ?int $value = null; |
||
21 | |||
22 | /** |
||
23 | * Dice constructor. |
||
24 | * |
||
25 | * Init the dice with no value. |
||
26 | */ |
||
27 | 9 | public function __construct() |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * Rolls the dice, random value between 1 and 6. |
||
34 | * |
||
35 | * @return int The value of the dice after rolling. |
||
36 | */ |
||
37 | 5 | public function roll(): int |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Get the current value of the dice. |
||
45 | * |
||
46 | * @throws LogicException if the dice has not been rolled yet. |
||
47 | * @return int The face value of the dice. |
||
48 | */ |
||
49 | 4 | public function getValue(): int |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * Get a string representation of the dice's current value. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | 2 | public function getAsString(): string |
|
68 |