DiceHand   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 40
ccs 0
cts 17
cp 0
rs 10
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A roll() 0 4 2
A getString() 0 7 2
A getValues() 0 7 2
A add() 0 3 1
A getNumberDice() 0 3 1
1
<?php
2
3
namespace App\Dice;
4
5
use App\Dice\Dice;
6
7
class DiceHand
8
{
9
    /** @var Dice[] $hand */
10
    private array $hand = [];
11
12
    public function add(Dice $die): void
13
    {
14
        $this->hand[] = $die;
15
    }
16
17
    public function roll(): void
18
    {
19
        foreach ($this->hand as $die) {
20
            $die->roll();
21
        }
22
    }
23
24
    public function getNumberDice(): int
25
    {
26
        return count($this->hand);
27
    }
28
29
    /** @return int[] Values */
30
    public function getValues(): array
31
    {
32
        $values = [];
33
        foreach ($this->hand as $die) {
34
            $values[] = $die->getValue();
35
        }
36
        return $values;
37
    }
38
39
    /** @return string[] Values */
40
    public function getString(): array
41
    {
42
        $values = [];
43
        foreach ($this->hand as $die) {
44
            $values[] = $die->getAsString();
45
        }
46
        return $values;
47
    }
48
}
49