Skip to content

Commit

Permalink
feat: added statistic resource
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepimpao committed May 22, 2024
1 parent 9b9360d commit 0179624
Show file tree
Hide file tree
Showing 13 changed files with 312 additions and 406 deletions.
57 changes: 12 additions & 45 deletions docs/03-supported-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -949,110 +949,77 @@ $response = $api->states()->getById(1);
### Statistics

- [Official documentation](https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/statistics)
- Cache default max age: `1 day`

#### `getAllByPlayerId`

```php
getAllByPlayerId(int $playerId, int $page = 1, int $perPage = 25, string $order = 'asc'): PlayerStatisticCollection
getAllByPlayerId(int $playerId): PlayerStatisticCollection
```

Get all statistics by player id per season:

```php
$statistics = $sportMonksFootball->statistics()->getAllByPlayerId(1);

foreach ($statistics->getData() as $statistic) {
foreach ($statistic->getDetails() as $detail) {
print_r($detail->getValue());
}
}
$response = $api->statistics()->getAllByPlayerId(1);
```

#### `getAllByTeamId`

```php
getAllByTeamId(int $teamId, int $page = 1, int $perPage = 25, string $order = 'asc'): TeamStatisticCollection
getAllByTeamId(int $teamId): TeamStatisticCollection
```

Get all statistics by team id per season:

```php
$statistics = $sportMonksFootball->statistics()->getAllByTeamId(1);

foreach ($statistics->getData() as $statistic) {
foreach ($statistic->getDetails() as $detail) {
print_r($detail->getValue());
}
}
$response = $api->statistics()->getAllByTeamId(1);
```

#### `getAllByCoachId`

```php
getAllByCoachId(int $coachId, int $page = 1, int $perPage = 25, string $order = 'asc'): CoachStatisticCollection
getAllByCoachId(int $coachId): CoachStatisticCollection
```

Get all statistics by coach id per season:

```php
$statistics = $sportMonksFootball->statistics()->getAllByCoachId(1);

foreach ($statistics->getData() as $statistic) {
foreach ($statistic->getDetails() as $detail) {
print_r($detail->getValue());
}
}
$response = $api->statistics()->getAllByCoachId(1);
```

#### `getAllByRefereeId`

```php
getAllByRefereeId(int $refereeId, int $page = 1, int $perPage = 25, string $order = 'asc'): RefereeStatisticCollection
getAllByRefereeId(int $refereeId): RefereeStatisticCollection
```

Get all statistics by referee id per season:

```php
$statistics = $sportMonksFootball->statistics()->getAllByRefereeId(1);

foreach ($statistics->getData() as $statistic) {
foreach ($statistic->getDetails() as $detail) {
print_r($detail->getValue());
}
}
$response = $api->statistics()->getAllByRefereeId(1);
```

#### `getAllByStageId`

```php
getAllByStageId(int $stageId, int $page = 1, int $perPage = 25, string $order = 'asc'): StatisticCollection
getAllByStageId(int $stageId): StatisticCollection
```

Get all statistics by stage id:

```php
$statistics = $sportMonksFootball->statistics()->getAllByStageId(1);

foreach ($statistics->getData() as $statistic) {
print_r($statistic->getValue());
}
$response = $api->statistics()->getAllByStageId(1);
```

#### `getAllByRoundId`

```php
getAllByRoundId(int $roundId, int $page = 1, int $perPage = 25, string $order = 'asc'): StatisticCollection
getAllByRoundId(int $roundId): StatisticCollection
```

Get all statistics by round id:

```php
$statistics = $sportMonksFootball->statistics()->getAllByRoundId(1);

foreach ($statistics->getData() as $statistic) {
print_r($statistic->getValue());
}
$response = $api->statistics()->getAllByRoundId(1);
```

### Teams
Expand Down
203 changes: 0 additions & 203 deletions src/Endpoint/StatisticEndpoint.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Entity/Statistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(array $data, string $timezone)
$this->value = $data['value'];

// include
// Season uses "statistic_type" instead of "type"
// season uses "statistic_type" instead of "type"
$this->type = (isset($data['type']) && \is_array($data['type'])) || isset($data['statistic_type'])
? new Type($data['statistic_type'] ?? $data['type'])
: null;
Expand Down
Loading

0 comments on commit 0179624

Please sign in to comment.