Dice   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10
ccs 0
cts 9
cp 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A roll() 0 4 1
A __construct() 0 3 1
A getValue() 0 3 1
A getAsString() 0 3 1
1
<?php
2
3
namespace App\Dice;
4
5
class Dice
6
{
7
    protected int $value;
8
9
    public function __construct()
10
    {
11
        $this->value = -1;
12
    }
13
14
    public function roll(): int
15
    {
16
        $this->value = random_int(1, 6);
17
        return $this->value;
18
    }
19
20
    /**
21
     * @return int Value
22
     * */
23
    public function getValue(): int
24
    {
25
        return $this->value;
26
    }
27
28
    public function getAsString(): string
29
    {
30
        return "[{$this->value}]";
31
    }
32
}
33