Exemple #1
0
 /**
  * Constructor of card
  *
  * @param string $figure one of FigureInterface::FIGURES
  * @param string $suit one of SuitInterface::SUITS
  */
 public function __construct(string $figure, string $suit = null)
 {
     static::checkFigureIsCorrect($figure);
     if ($figure === self::FIGURE_JOKER) {
         if ($suit !== null) {
             throw CardException::jokerWithSuit($suit);
         }
     } else {
         static::checkSuitIsCorrect($suit);
     }
     $this->figure = $figure;
     $this->suit = $suit;
 }
Exemple #2
0
 /**
  * @return array
  */
 public static function constructFailProvider() : array
 {
     return array(array(CardException::incorrectFigure('notExistedFigure'), 'notExistedFigure', null), array(CardException::incorrectFigure('notExistedFigure'), 'notExistedFigure', 'notExistedSuit'), array(CardException::incorrectSuit('notExistedSuit'), FigureInterface::FIGURE_ACE, 'notExistedSuit'), array(CardException::incorrectFigure('notExistedFigure'), 'notExistedFigure', SuitInterface::SUIT_HEART), array(CardException::jokerWithSuit('notExistedSuit'), FigureInterface::FIGURE_JOKER, 'notExistedSuit'), array(CardException::jokerWithSuit(SuitInterface::SUIT_HEART), FigureInterface::FIGURE_JOKER, SuitInterface::SUIT_HEART));
 }