PHP code example of guillegf / secret-santa

1. Go to this page and download the library: Download guillegf/secret-santa 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/ */

    

guillegf / secret-santa example snippets



$secretSanta = new SecretSanta();
$secretSanta->addPlayer('Player1', '[email protected]')
  ->addPlayer('Player2', '[email protected]')
  ->addCouple('Player3', '[email protected]', 'Couple3', '[email protected]')
  ->addCouple('Player4', '[email protected]', 'Couple4', '[email protected]')
  ->addExclusivePlayers(
      ['Player5', '[email protected]'],
      ['Player6', '[email protected]'],
      ['Player7', '[email protected]'],
      ['Player8', '[email protected]']
  );
  
foreach ($secretSanta->play() as $player) {
     echo ("{$player->name()} ({$player->email()}): {$player->secretSanta()->name()}\n");
}

Player1 ([email protected]): Player5
Player2 ([email protected]): Player7
Player3 ([email protected]): Player2
Couple3 ([email protected]): Player8
Player4 ([email protected]): Player3
Couple4 ([email protected]): Player6
Player5 ([email protected]): Player4
Player6 ([email protected]): Player1
Player7 ([email protected]): Couple3
Player8 ([email protected]): Couple4