Total Complexity | 7 |
Total Lines | 93 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class Card |
||
9 | { |
||
10 | /** @var string */ |
||
11 | private string $suit; |
||
12 | |||
13 | /** @var string */ |
||
14 | private string $value; |
||
15 | |||
16 | /** |
||
17 | * Card constructor. |
||
18 | * |
||
19 | * @param string $value |
||
20 | * @param string $suit |
||
21 | */ |
||
22 | 52 | public function __construct(string $suit, string $value) |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get the suit of the card (Hearts, Diamonds, Clubs, Spades). |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | 7 | public function getSuit(): string |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get the value of the card (Ace, 2, 3, King). |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 19 | public function getValue(): string |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get the numeric/point value of the card. |
||
50 | * |
||
51 | * @return int |
||
52 | */ |
||
53 | 3 | public function getNumericValue(): int |
|
61 | 3 | }; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * Get the numeric/point value of the card for black jack game. |
||
66 | * |
||
67 | * @return int |
||
68 | */ |
||
69 | 8 | public function getBlackJackNumericValue(): int |
|
77 | 8 | }; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * String representation of the card. |
||
82 | * |
||
83 | * @return string The card in the format "Value of Suit" -> "King of Hearts". |
||
84 | */ |
||
85 | 1 | public function __toString(): string |
|
88 | } |
||
89 | |||
90 | |||
91 | /** |
||
92 | * Convert the card to an array. |
||
93 | * |
||
94 | * @return array{value: string, suit: string} |
||
95 | */ |
||
96 | 8 | public function toArray(): array |
|
104 |