gift-factory / secret-santa-picker
Pick a random player for each other player of a given group
1.1.0
2023-12-09 13:31 UTC
Requires
- php: ^8.3
Requires (Dev)
- phpunit/phpunit: ^10.4.2
README
Pick a random player for each other player of a given group
Install
composer require gift-factory/secret-santa-picker
Use
$players = new PlayerList([ new Player('Anna'), new Player('Bob'), // Bob and Dane won't be picked to send a gift to Chuck new Player('Chuck', exclusions: ['Bob', 'Dane']), new Player('Dane'), // Edith and Fiona will be mutually excluded [new Player('Edith'), new Player('Fiona')], ]); $picker = new Picker(); $draw = $picker->pick($players); foreach ($draw as $donor => $receiver) { mail( $donor->email, 'Secret Santa', " Hello $donor->userName, This year, you'll be the santa of $receiver->userName, Here is the address where to send your gift: $receiver->realName $receiver->address ", ); }
Thanks
And a big thank-you to Jet Brains who provides such a great IDE: