Issues (24)

src/Card/CardHand.php (3 issues)

1
<?php
2
3
namespace App\Card;
4
5
use App\Card\CardGraphic;
6
7
/**
8
 * CardHand - holds the card drawn from the deck by a player
9
 */
10
class CardHand
11
{
12
    /**
13
     * hand - comntains the cards in a hand
14
     *
15
     * @var array<CardGraphic> $hand
16
     */
17
    private array $hand = [];
18
19
    /**
20
     * add - adds a card to the hand
21
     *
22
     * @param  CardGraphic $card
23
     */
24 6
    public function add(CardGraphic $card): void
25
    {
26 6
        $this->hand[] = $card;
27
    }
28
29
    /**
30
     * getNumberCards - returns the number of cards in the hand
31
     *
32
     * @return int
33
     */
34 1
    public function getNumberCards(): int
35
    {
36 1
        return count($this->hand);
37
    }
38
39
    /**
40
     * getValues - returns the values of the cards in the hand
41
     * @return list<int|null>
0 ignored issues
show
The type App\Card\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...
42
     */
43 1
    public function getValues(): array
44
    {
45 1
        $values = [];
46 1
        foreach ($this->hand as $card) {
47 1
            $values[] = $card->getValue();
48
        }
49 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\Card\list.
Loading history...
50
    }
51
52
    /**
53
     * getString - returns the string representation of the cards in the hand
54
     *
55
     * @return list<string|null>
56
     */
57 1
    public function getString(): array
58
    {
59 1
        $values = [];
60 1
        foreach ($this->hand as $card) {
61 1
            $values[] = $card->getAsString();
62
        }
63 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\Card\list.
Loading history...
64
    }
65
    /**
66
     * getHand
67
     *
68
     * @return array<CardGraphic>
69
     */
70 5
    public function getHand(): array
71
    {
72 5
        return $this->hand;
73
    }
74
}
75