承接 rastor/expected-goals-client 相关项目开发

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

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

rastor/expected-goals-client

最新稳定版本:v1.8

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 ... 

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固