Skip to content

Commit

Permalink
feat: added team resource
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepimpao committed May 22, 2024
1 parent 0179624 commit 61432ff
Show file tree
Hide file tree
Showing 14 changed files with 298 additions and 305 deletions.
34 changes: 8 additions & 26 deletions docs/03-supported-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -1025,22 +1025,17 @@ $response = $api->statistics()->getAllByRoundId(1);
### Teams

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

#### `getAll`

```php
getAll(int $page = 1, int $perPage = 25, string $order = 'asc'): TeamCollection
getAll(): TeamCollection
```

Get all teams:

```php
$teams = $sportMonksFootball->teams()->getAll();

foreach ($teams->getData() as $team) {
echo $team->getName();
}
$response = $api->teams()->getAll();
```

#### `getById`
Expand All @@ -1052,24 +1047,19 @@ getById(int $id): TeamItem
Get team by id:

```php
$team = $sportMonksFootball->teams()->getById(1);
echo $team->getData()->getName();
$response = $api->teams()->getById(1);
```

#### `getAllByCountryId`

```php
getAllByCountryId(int $countryId, int $page = 1, int $perPage = 25, string $order = 'asc'): TeamCollection
getAllByCountryId(int $countryId): TeamCollection
```

Get all teams by country id:

```php
$teams = $sportMonksFootball->teams()->getAllByCountryId(1);

foreach ($teams->getData() as $team) {
echo $team->getName();
}
$response = $api->teams()->getAllByCountryId(1);
```

#### `getAllBySeasonId`
Expand All @@ -1081,27 +1071,19 @@ getAllBySeasonId(int $seasonId): TeamCollection
Get all teams by season id:

```php
$teams = $sportMonksFootball->teams()->getAllBySeasonId(1);

foreach ($teams->getData() as $team) {
echo $team->getName();
}
$response = $api->teams()->getAllBySeasonId(1);
```

#### `getAllBySearchQuery`

```php
getAllBySearchQuery(string $query, int $page = 1, int $perPage = 25, string $order = 'asc'): TeamCollection
getAllBySearchQuery(string $query): TeamCollection
```

Get all teams by search query:

```php
$teams = $sportMonksFootball->teams()->getAllBySearchQuery('sporting');

foreach ($teams->getData() as $team) {
echo $team->getName();
}
$response = $api->teams()->getAllBySearchQuery('sporting');
```

### Team Squads
Expand Down
2 changes: 1 addition & 1 deletion docs/05-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@
- `getName()`: `?string`
- `getShortCode()`: `?string`
- `getImagePath()`: `?string`
- `getFoundedAt()`: `?int`
- `getFoundedIn()`: `?int`
- `getType()`: `?string`
- `isPlaceholder()`: `?bool`
- `getLastPlayedAt()`: `?\DateTimeImmutable`
Expand Down
143 changes: 0 additions & 143 deletions src/Endpoint/TeamEndpoint.php

This file was deleted.

16 changes: 4 additions & 12 deletions src/Entity/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Team

private ?string $imagePath;

private ?int $foundedAt;
private ?int $foundedIn;

private ?string $type;

Expand Down Expand Up @@ -68,8 +68,6 @@ class Team
/** @var ?Social[] */
private ?array $socials;

private ?TeamMeta $meta;

/** @var ?TeamCoach[] */
private ?array $coaches;

Expand All @@ -88,7 +86,7 @@ public function __construct(array $data, string $timezone)
$this->name = $data['name'] ?? null;
$this->shortCode = $data['short_code'] ?? null;
$this->imagePath = $data['image_path'] ?? null;
$this->foundedAt = $data['founded'] ?? null;
$this->foundedIn = $data['founded'] ?? null;
$this->type = $data['type'] ?? null;
$this->isPlaceholder = $data['placeholder'] ?? null;
$this->lastPlayedAt = isset($data['last_played_at']) ? new \DateTimeImmutable($data['last_played_at']) : null;
Expand All @@ -107,7 +105,6 @@ public function __construct(array $data, string $timezone)
$this->sidelinedHistory = isset($data['sidelinedhistory']) ? $this->createEntityCollection(Sidelined::class, $data['sidelinedhistory'], $timezone) : null;
$this->trophies = isset($data['trophies']) ? $this->createEntityCollection(ParticipantTrophy::class, $data['trophies'], $timezone) : null;
$this->socials = isset($data['socials']) ? $this->createEntityCollection(Social::class, $data['socials']) : null;
$this->meta = isset($data['meta']) ? new TeamMeta($data['meta']) : null;
$this->coaches = isset($data['coaches']) ? $this->createEntityCollection(TeamCoach::class, $data['coaches'], $timezone) : null;
$this->statistics = isset($data['statistics']) ? $this->createEntityCollection(TeamStatistic::class, $data['statistics'], $timezone) : null;
}
Expand Down Expand Up @@ -152,9 +149,9 @@ public function getImagePath(): ?string
return $this->imagePath;
}

public function getFoundedAt(): ?int
public function getFoundedIn(): ?int
{
return $this->foundedAt;
return $this->foundedIn;
}

public function getType(): ?string
Expand Down Expand Up @@ -237,11 +234,6 @@ public function getSocials(): ?array
return $this->socials;
}

public function getMeta(): ?TeamMeta
{
return $this->meta;
}

public function getCoaches(): ?array
{
return $this->coaches;
Expand Down
34 changes: 0 additions & 34 deletions src/Entity/TeamMeta.php

This file was deleted.

Loading

0 comments on commit 61432ff

Please sign in to comment.