avantar / bracket-generator
Simple Bracket Generator
0.1.1
2020-12-31 11:55 UTC
Requires
- php: >=7.4.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Simple Bracket Generator
Requirements:
- PHP 7.4+
How to use:
- Create new instance of the Bracket Generator:
$generator = new \BracketGenerator\Generator();
- Use the
generate
method to get array with bracket games. You need to pass the number of tournament participants:
$generator->generate(8);
- You should get an array of games:
[ [ 'id' => 1, 'round' => 1, 'game_in_round' => 1, 'next_game_id' => 5 ], [ 'id' => 2, 'round' => 1, 'game_in_round' => 2, 'next_game_id' => 5 ], [ 'id' => 3, 'round' => 1, 'game_in_round' => 3, 'next_game_id' => 6 ], [ 'id' => 4, 'round' => 1, 'game_in_round' => 4, 'next_game_id' => 6 ], [ 'id' => 5, 'round' => 2, 'game_in_round' => 1, 'next_game_id' => 7 ], [ 'id' => 6, 'round' => 2, 'game_in_round' => 2, 'next_game_id' => 7 ], [ 'id' => 7, 'round' => 3, 'game_in_round' => 1, 'next_game_id' => null ], ];
For now, the library is able to generate only a single elimination bracket. Feel free to contribute. Thanks!