| Total Complexity | 4 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Dice |
||
| 6 | { |
||
| 7 | protected int $value; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * __construct. |
||
| 11 | * |
||
| 12 | * Constructor of the class |
||
| 13 | * |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | 10 | public function __construct() |
|
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * roll. |
||
| 23 | * |
||
| 24 | * Roll a new value for the dice (1-6) |
||
| 25 | */ |
||
| 26 | 7 | public function roll(): int |
|
| 27 | { |
||
| 28 | 7 | $this->value = random_int(1, 6); |
|
| 29 | |||
| 30 | 7 | return $this->value; |
|
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * getValue. |
||
| 35 | * |
||
| 36 | * Returns the value of the dice |
||
| 37 | */ |
||
| 38 | 2 | public function getValue(): int |
|
| 39 | { |
||
| 40 | 2 | return $this->value; |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * getString. |
||
| 45 | * |
||
| 46 | * Returns the value of the dice as a string |
||
| 47 | */ |
||
| 48 | 2 | public function getString(): string |
|
| 51 | } |
||
| 52 | } |
||
| 53 |