| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 33.33% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class CardFactory |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Whether to create graphic cards or plain text cards. |
||
| 15 | */ |
||
| 16 | private bool $useGraphics; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * CardFactory constructor. |
||
| 20 | * |
||
| 21 | * @param bool $useGraphics true to return CardGraphic instances, false for Card |
||
| 22 | */ |
||
| 23 | 32 | public function __construct(bool $useGraphics = false) |
|
| 24 | { |
||
| 25 | 32 | $this->useGraphics = $useGraphics; |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Creates a card instance based on the factory's setting. |
||
| 30 | * |
||
| 31 | * @param string $suit The suit of the card (e.g. Hearts). |
||
| 32 | * @param string $value The value of the card (e.g. 10, Queen). |
||
| 33 | * |
||
| 34 | * @return Card|CardGraphic a new instance of Card or CardGraphic |
||
| 35 | */ |
||
| 36 | public function createCard(string $suit, string $value) |
||
| 43 | } |
||
| 44 | } |
||
| 45 |