CardHand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 34
rs 10
ccs 9
cts 9
cp 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValues() 0 7 2
A add() 0 3 1
A getNumberCards() 0 3 1
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