コード例 #1
0
ファイル: CardTest.php プロジェクト: bnowak/card-game
 public function testCheckSuitIsCorrect()
 {
     foreach (SuitInterface::SUITS as $suit) {
         Card::checkSuitIsCorrect($suit);
         $this->addToAssertionCount(1);
     }
     $expectedException = CardException::incorrectSuit('notExistedSuit');
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     Card::checkSuitIsCorrect('notExistedSuit');
 }
コード例 #2
0
ファイル: CardCollection.php プロジェクト: bnowak/card-game
 /**
  * Is card with $suit in collection
  *
  * @param string $suit
  * @return bool
  */
 public function hasCardWithSuit(string $suit) : bool
 {
     Card::checkSuitIsCorrect($suit);
     foreach ($this->cards as $card) {
         if ($card->getSuit() === $suit) {
             return true;
         }
     }
     return false;
 }