PHP code example of apetitpa / card-factory

1. Go to this page and download the library: Download apetitpa/card-factory library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

apetitpa / card-factory example snippets


use Apetitpa\CardFactory\Model\Deck;

// Create a standard deck of 52 playing cards (shuffled by default)
$deck = Deck::createStandardDeck();

// To create an ordered (not shuffled) deck, use:
$deck = Deck::createStandardDeck(false);

// Shuffle the deck
$deck->shuffle();

// Draw the top card from the deck
$card = $deck->drawCard();

// Check the card's suit and value
$suit = $card->getSuit();
$value = $card->getValue();