Issues (10)

src/Dice/DiceHand.php (2 issues)

1
<?php
2
3
namespace App\Dice;
4
5
use App\Dice\Dice;
6
7
class DiceHand
8
{
9
    /**
10
     * @var Dice[]
11
     */
12
    private array $hand = [];
13
14 2
    public function add(Dice $die): void
15
    {
16 2
        $this->hand[] = $die;
17
    }
18
19 1
    public function roll(): void
20
    {
21 1
        foreach ($this->hand as $die) {
22 1
            $die->roll();
23
        }
24
    }
25
26 1
    public function getNumberDices(): int
27
    {
28 1
        return count($this->hand);
29
    }
30
31
    /**
32
     * @return list<int|null>
0 ignored issues
show
The type App\Dice\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
     */
34 1
    public function getValues(): array
35
    {
36 1
        $values = [];
37 1
        foreach ($this->hand as $die) {
38 1
            $values[] = $die->getValue();
39
        }
40 1
        return $values;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $values returns the type array which is incompatible with the documented return type App\Dice\list.
Loading history...
41
    }
42
43
    /**
44
     * @return int
45
     */
46 1
    public function sum(): int
47
    {
48 1
        $sum = 0;
49 1
        foreach ($this->hand as $die) {
50 1
            $sum += $die->getValue();
51
        }
52 1
        return $sum;
53
    }
54
55
    /**
56
     * @return string[]
57
     */
58 1
    public function getString(): array
59
    {
60 1
        $values = [];
61 1
        foreach ($this->hand as $die) {
62 1
            $values[] = $die->getAsString();
63
        }
64 1
        return $values;
65
    }
66
}
67