src/Card.php
/**
     * Return an array of Card instances given an array or a string
     * Array can contain mixed instances of Card or a short Card description string
     * e.g. [new Card('Ah'), '3s', '4c', new Card('9s')]
     * or
     * e.g. 'Ah3s4c'
     *
     * @param array|string $cards
     */
Return an array of Card instances given an array or a string
Array can contain mixed instances of Card or a short Card description string
e.g.

@param array|string $cards
Return an array of Card instances given an array or a string Array can contain mixed instances of Card or a short Card description string e . g . @param array|string $cards
public static function convertToCards($cards)
    {
        if (is_array($cards))
        {
            return array_map(fn($card) => ($card instanceof Card) ? $card : new Card($card), $cards);
        }
        if (is_string($cards))
        {
            $shortCards = str_split($cards, 2);
            return array_map(fn($shortCardValue) => new Card($shortCardValue), $shortCards);
        }
        throw new InvalidCardException('Invalid argument type for Cards');
    }
public static function convertToCards ( $ cards ) { if ( is_array ( $ cards ) ) { return array_map ( fn ( $ card ) => ( $ card instanceof Card ) ? $ card : new Card ( $ card ) , $ cards ) ; } if ( is_string ( $ cards ) ) { $ shortCards = str_split ( $ cards , 2 ) ; return array_map ( fn ( $ shortCardValue ) => new Card ( $ shortCardValue ) , $ shortCards ) ; } throw new InvalidCardException ( 'Invalid argument type for Cards' ) ; }
Return an array of Card instances given an array or a string
 Array can contain mixed instances of Card or a short Card description string
 e.g.
Return an array of Card instances given an array or a string Array can contain mixed instances of Card or a short Card description string e . g .
// Map over array. // If it's already an instance of Card then return the Card instance // Else try to instantiate a Card with the value // Split string in to every two characters // Try to instantiate a Card instance with every two characters // If it's not an array or string throw exception