infocyph / game-draw
Generates Item and Item count for winners.
4.1.1
2026-04-20 11:10 UTC
Requires
- php: >=8.4
- ext-bcmath: *
- psr/cache: ^3.0
Requires (Dev)
- captainhook/captainhook: ^5.29.2
- laravel/pint: ^1.29
- pestphp/pest: ^4.6.2
- pestphp/pest-plugin-drift: ^4.1
- phpbench/phpbench: ^1.6.1
- phpstan/phpstan: ^2.1.50
- rector/rector: ^2.4.2
- squizlabs/php_codesniffer: ^4.0.1
- symfony/var-dumper: ^7.3 || ^8.0.8
- tomasvotruba/cognitive-complexity: ^1.1
- vimeo/psalm: ^6.16.1
README
Unified PHP draw engine with a single request/response contract for item, user, and campaign draw methods.
Campaign state uses PSR-6 (Psr\Cache\CacheItemPoolInterface) via options.cachePool.
Install
Requirements:
- PHP 8.4+
ext-bcmath
composer require infocyph/game-draw
Quick Example
<?php use Infocyph\Draw\Draw; $draw = new Draw(); $result = $draw->execute([ 'method' => 'lucky', 'items' => [ ['item' => 'gift_a', 'chances' => 10, 'amountMode' => 'list', 'amounts' => [1, 2]], ['item' => 'gift_b', 'chances' => 20, 'amountMode' => 'weighted', 'amounts' => ['5' => 0.25, '10' => 0.75]], ], 'options' => ['count' => 2], ]);
Supported Methods
luckygrandprobability,elimination,weightedElimination,roundRobin,cumulativebatched,timeBased,weightedBatch,sequential,rangeWeightedcampaign.run,campaign.batch,campaign.simulate
Documentation
Published docs: https://docs.infocyph.com/projects/Game-Draw/