DiceHand   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

5 Methods

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