CardHand::getValues()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
ccs 5
cts 5
cp 1
crap 2
1
<?php
2
3
namespace App\Card;
4
5
use App\Card\Card;
6
7
/**
8
 * Methods for CardHand class.
9
 */
10
class CardHand
11
{
12
    /**
13
     * @var Card[]
14
     */
15
    private array $hand = [];
16
17
    /**
18
     * Add a card to the hand.
19
     */
20 7
    public function add(Card $card): void
21
    {
22 7
        $this->hand[] = $card;
23
    }
24
25
    /**
26
     * Return the values of the cards at hand.
27
     * @return string[][]
28
     */
29 8
    public function getValues(): array
30
    {
31 8
        $values = [];
32 8
        foreach ($this->hand as $card) {
33 6
            $values[] = $card->getValue();
34
        }
35 8
        return $values;
36
    }
37
38
    /**
39
     * Return the number of cards at hand.
40
     */
41 1
    public function getNumberCards(): int
42
    {
43 1
        return count($this->hand);
44
    }
45
}
46