承接 philicevic/berger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

philicevic/berger

最新稳定版本:0.3.0

Composer 安装命令:

composer require philicevic/berger

包简介

A tool to create round robin tournament matchups using the Berger tables

README 文档

README

This package allows you to generate round robin tournament matchups based on the Berger tables.

Usage

use Philicevic\Berger\Services\RoundRobin;

// this creates 6 rounds where teams play each other twice
$teams = ['A', 'B', 'C', 'D'];
$matchesAgainstEachOther = 2;
$rounds = RoundRobin::makeFromTeams($teams, $matchesAgainstEachOther);


// or use it step by step

$teams = ['A', 'B', 'C', 'D'];
$rr = RoundRobin::create();
$rr->setTeams($teams);
$rounds = $rr->make();

$rounds will be an array of Round objects.

Round

foreach ($rounds as $round) {
    // get array of fixtures
    $round->fixtures;
    
    // get number of round
    $round->number;
    
    // add fixture to round
    $round->addFixture($fixture);
    
    // remove fixture from round by index
    $round->removeFixture($index);
    
    // format round as array
    $round->toArray();
}

// $round->toArray() will return something like this
[
    [
        [
            'home' => 'A',
            'away' => 'C',
            'round' => 1,
        ],
        [
            'home' => 'B',
            'away' => 'D',
            'round' => 1,
        ],
    ],
    [
        [
            'home' => 'C',
            'away' => 'B',
            'round' => 2,
        ],
        [
            'home' => 'D',
            'away' => 'A',
            'round' => 2,
        ],
    ],
    [
        [
            'home' => 'A',
            'away' => 'B',
            'round' => 3,
        ],
        [
            'home' => 'C',
            'away' => 'D',
            'round' => 3,
        ],
    ],
]

Fixture

Every fixture has two properties.

$fixture->home
$fixture->away

Both contain just the name of the team.

You could also access the teams via the getTeams method.

// returns ["Team A", "Team B"]
$fixture->getTeams()

If you want to swap the places of the teams for a fixture you can also do that.

$fixture->swapTeams()

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固