Passed
Push — main ( a387cb...339f6d )
by Cornelia
07:55
created

CardHand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCards() 0 3 1
A addCard() 0 3 1
1
<?php
2
3
namespace App\Card;
4
5
/**
6
 * Class CardHand.
7
 *
8
 * Represents a hand of playing cards.
9
 */
10
class CardHand
11
{
12
    /**
13
     * @var Card[] array of Card objects representing the hand
14
     */
15
    private array $cards = [];
16
17
    /**
18
     * Adds a card to the hand.
19
     *
20
     * @param Card $card the card to add
21
     */
22 16
    public function addCard(Card $card): void
23
    {
24 16
        $this->cards[] = $card;
25
    }
26
27
    /**
28
     * Returns all cards in the hand.
29
     *
30
     * @return Card[] an array of Card objects
31
     */
32 18
    public function getCards(): array
33
    {
34 18
        return $this->cards;
35
    }
36
}
37