/** * @param Card $cardToFind * @param HandInterface $hand * * @return Hand|null */ public function search(Card $cardToFind, HandInterface $hand) { $matches = 0; $cards = []; foreach ($hand->getCards() as $key => $card) { if ($card->getFaceValue() === $cardToFind->getFaceValue()) { ++$matches; $cards[] = $card; } } return count($cards) ? new Hand(...$cards) : null; }
public function test_should_have_a_valid_suit() { $card = new Card(2, Suit::spades()); $this->assertInstanceOf(Suit::class, $card->getSuit()); }