Skip to content

Latest commit

 

History

History
77 lines (65 loc) · 1.74 KB

README.md

File metadata and controls

77 lines (65 loc) · 1.74 KB

bracket-generator

Simple Bracket Generator

codecov Maintainability

Requirements:

  1. PHP 7.4+

How to use:

  1. Create new instance of the Bracket Generator:
$generator = new \BracketGenerator\Generator();
  1. Use the generate method to get array with bracket games. You need to pass the number of tournament participants:
$generator->generate(8);
  1. 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!