Dice::getString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Dice;
4
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()
17
    {
18 10
        $this->value = random_int(1, 6);
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
49
    {
50 2
        return "[{$this->value}]";
51
    }
52
}
53