rastor/expected-goals-client
Composer 安装命令:
composer require rastor/expected-goals-client
包简介
Football (Soccer) Expected Goals Statistics (xG) API Client
README 文档
README
PHP client for football (soccer) expected goals (xG) statistics API. It provides a list of events with xG metric for every game of more than 80 leagues.
Usage
To install the latest version of rastor/expected-goals-client use composer.
composer require rastor/expected-goals-client
Example usage
Basic Usage
use ExpectedGoalsClient\ExpectedGoalsClient; $client = new ExpectedGoalsClient('Your API Key'); $countries = $client->getCountries(); // list of countries $leagues = $client->getTournaments($countryId); // list of tournaments for specified country $seasons = $client->getSeasons($leagueId); // list of seasons for specified tournament $fixtures = $client->getFixtures($seasonId); // list of fixtures for specified season $fixture = $client->getFixture($fixtureId); // get one fixture
Calculating xg90 (expected goals for 90 minutes) metric for every team of available seasons
foreach ($client->getCountries() as $country) { foreach ($client->getTournaments($country->id) as $league) { foreach ($client->getSeasons($league->id) as $season) { echo "{$country->name}. {$league->name} ({$season->name})\n"; echo "=====\n"; $seasonFixtures = $client->getFixtures($season->id); $expectedGoals = []; $minutes = []; $teamNames = []; foreach ($seasonFixtures as $fixture) { if (!isset($teamNames[$fixture->homeTeam->id])) { $teamNames[$fixture->homeTeam->id] = $fixture->homeTeam->name; $minutes[$fixture->homeTeam->id] = 0; } if (!isset($teamNames[$fixture->awayTeam->id])) { $teamNames[$fixture->awayTeam->id] = $fixture->awayTeam->name; $minutes[$fixture->awayTeam->id] = 0; } $minutes[$fixture->homeTeam->id] += $fixture->duration->firstHalf + $fixture->duration->secondHalf; $minutes[$fixture->awayTeam->id] += $fixture->duration->firstHalf + $fixture->duration->secondHalf; foreach ($fixture->events as $event) { if (!$event->xg) { continue; } if (!isset($expectedGoals[$event->teamId])) { $expectedGoals[$event->teamId] = 0; } $expectedGoals[$event->teamId] += $event->xg; } } $result = []; foreach ($expectedGoals as $teamId => $value) { $result[$teamId] = ($value / $minutes[$teamId]) * 90; } arsort($result); foreach ($result as $teamId => $value) { echo "$teamNames[$teamId]: {$value}\n"; } echo PHP_EOL; } } }
Example Output:
England. Premier League (2016/2017)
=====
Manchester City: 2.2112692731278
Tottenham: 2.0528394039735
Chelsea: 1.8262697313764
Arsenal: 1.7997027250206
Liverpool: 1.6997235277855
Manchester Utd: 1.6932413793103
Southampton: 1.4393784530387
Everton: 1.3932328539823
Bournemouth: 1.2910729023384
Stoke: 1.2596034150372
Leicester: 1.2125481563016
West Ham: 1.2049150684932
Crystal Palace: 1.1981870860927
Swansea: 1.0498671831765
Burnley: 0.95350882028666
Watford: 0.9309592061742
West Brom: 0.91582526956041
Sunderland: 0.9
Hull: 0.83620127177219
Middlesbrough: 0.69719434433047
England. Premier League (2017/2018)
=====
Manchester City: 2.3988232044199
Liverpool: 1.8711009933775
Tottenham: 1.8331631244825
Arsenal: 1.6883651452282
Manchester Utd: 1.5726460005536
Chelsea: 1.4510011061947
Crystal Palace: 1.4030157415079
Leicester: 1.2518565517241
Watford: 1.1562657534247
Everton: 1.1204689655172
Newcastle: 1.0640897755611
West Ham: 1.0446826051113
Bournemouth: 0.99573626373627
Brighton: 0.98392668703138
Southampton: 0.92284729878721
Stoke: 0.8937382661513
Burnley: 0.88359102244389
West Brom: 0.83442573163998
Swansea: 0.77539422543032
Huddersfield: 0.75367533185841
...
rastor/expected-goals-client 适用场景与选型建议
rastor/expected-goals-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.11k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 05 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「soccer」 「xg」 「football」 「expected goals」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rastor/expected-goals-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rastor/expected-goals-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rastor/expected-goals-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
TYPO3 extension to manage sports competitions and clubs.
Laravel wrapper for Soccerama score API calls v2.0. Fork of rebing/laravel-soccerama
Laravel wrapper for Soccerama score API calls v2.0. Fork of rebing/laravel-soccerama
Laravel Wrapper for MFL (MyFantasyLeague) API PHP Library
Simpletipp
Laravel wrapper for Soccerama score API calls v2.0. Fork of rebing/laravel-soccerama
统计信息
- 总下载量: 5.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-31