diff --git a/docs/03-supported-endpoints.md b/docs/03-supported-endpoints.md index 6ee811f..3913bba 100644 --- a/docs/03-supported-endpoints.md +++ b/docs/03-supported-endpoints.md @@ -1089,7 +1089,6 @@ $response = $api->teams()->getAllBySearchQuery('sporting'); ### Team Squads - [Official documentation](https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/team-squads) -- Cache default max age: `1 day` #### `getAllByTeamId` @@ -1100,11 +1099,7 @@ getAllByTeamId(int $teamId): TeamSquadCollection Get complete team squad by team id: ```php -$squad = $sportMonksFootball->teamSquads()->getAllByTeamId(1); - -foreach ($squad->getData() as $player) { - echo $player->getPlayerId(); -} +$response = $api->teamSquads()->getAllByTeamId(1); ``` #### `getAllExtendedByTeamId` @@ -1112,14 +1107,10 @@ foreach ($squad->getData() as $player) { getAllExtendedByTeamId(int $teamId): PlayerCollection ``` -Get complete team squad entried based on the current season by team id: +Get complete team squad entries based on the current season by team id: ```php -$squad = $sportMonksFootball->teamSquads()->getAllExtendedByTeamId(1); - -foreach ($squad->getData() as $player) { - echo $player->getName(); -} +$response = $api->teamSquads()->getAllExtendedByTeamId(1); ``` #### `getAllBySeasonIdAndTeamId` @@ -1131,11 +1122,7 @@ getAllBySeasonIdAndTeamId(int $seasonId, int $teamId): TeamSquadCollection Get complete team squad of one team by season id and team id: ```php -$squad = $sportMonksFootball->teamSquads()->getAllBySeasonIdAndTeamId(1, 1); - -foreach ($squad->getData() as $player) { - echo $player->getPlayerId(); -} +$response = $api->teamSquads()->getAllBySeasonIdAndTeamId(1, 1); ``` ### Topscorers diff --git a/docs/05-entities.md b/docs/05-entities.md index 38eed01..9ce7111 100644 --- a/docs/05-entities.md +++ b/docs/05-entities.md @@ -234,7 +234,7 @@ - `getStateId()`: `int` - `getVenueId()`: `?int` - `getName()`: `?string` -- `getStartingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` - `getResultInfo()`: `?string` - `getLeg()`: `?string` - `getDetails()`: `?string` @@ -330,8 +330,8 @@ - `getSeasonId()`: `int` - `getStageId()`: `int` - `getName()`: `?string` -- `getStartingAt()`: `?\DateTimeImmutable` -- `getEndingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `hasGamesInCurrentWeek()`: `?bool` - `isCurrent()`: `?bool` - `hasFinished()`: `?bool` @@ -419,8 +419,8 @@ - `getId()`: `int` - `getFixtureId()`: `int` - `getTypeId()`: `int` -- `getStartedAt()`: `?\DateTimeImmutable` -- `getEndedAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `getCountsFrom()`: `?int` - `isTicking()`: `?bool` - `getSortOrder()`: `?int` @@ -553,8 +553,8 @@ - `getName()`: `?string` - `hasFinished()`: `?bool` - `isCurrent()`: `?bool` -- `getStartingAt()`: `?\DateTimeImmutable` -- `getEndingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `hasGamesInCurrentWeek()`: `?bool` - `getSport()`: [`?Sport`](#sport) (`sport` include is required) - `getLeague()`: [`?League`](#league) (`league` include is required) @@ -586,8 +586,8 @@ - `hasFinished()`: `?bool` - `isPending()`: `?bool` - `isCurrent()`: `?bool` -- `getStartingAt()`: `?\DateTimeImmutable` -- `getEndingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `getStandingsRecalculatedAt()`: `?\DateTimeImmutable` - `hasGamesInCurrentWeek()`: `?bool` - `getSport()`: [`?Sport`](#sport) (`sport` include is required) @@ -608,8 +608,8 @@ - `getTeamId()`: `int` - `getSeasonId()`: `?int` - `getCategory()`: `?string` -- `getStartingAt()`: `?\DateTimeImmutable` -- `getEndingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `getGamesMissed()`: `?int` - `isCompleted()`: `?bool` - `getTeam()`: [`?Team`](#team) (`team` include is required) @@ -643,8 +643,8 @@ - `getSortOrder()`: `?int` - `hasFinished()`: `?bool` - `isCurrent()`: `?bool` -- `getStartingAt()`: `?\DateTimeImmutable` -- `getEndingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `hasGamesInCurrentWeek()`: `?bool` - `getTieBreakerRuleId()`: `?bool` - `getLeague()`: [`?League`](#league) (`league` include is required) @@ -786,8 +786,8 @@ - `getCoachId()`: `int` - `getPositionId()`: `int` - `isActive()`: `?bool` -- `getStartedAt()`: `?\DateTimeImmutable` -- `getEndedAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `isTemporary()`: `?bool` - `getTeam()`: [`?Team`](#team) (`team` include is required) - `getCoach()`: [`?Coach`](#coach) (`coach` include is required) @@ -825,8 +825,8 @@ - `getTeamId()`: `int` - `getPosition()`: `int` - `getDetailedPositionId()`: `?int` -- `getStartingAt()`: `?\DateTimeImmutable` -- `getEndingAt()`: `?\DateTimeImmutable` +- `getStartAt()`: `?\DateTimeImmutable` +- `getEndAt()`: `?\DateTimeImmutable` - `isCaptain()`: `?bool` - `getJerseyNumber()`: `?int` - `getTeam()`: [`?Team`](#team) (`team` include is required) diff --git a/src/Endpoint/TeamSquadEndpoint.php b/src/Endpoint/TeamSquadEndpoint.php deleted file mode 100644 index dfbdc62..0000000 --- a/src/Endpoint/TeamSquadEndpoint.php +++ /dev/null @@ -1,71 +0,0 @@ -sendRequest( - method: 'GET', - path: $this->formatPath('/v3/football/squads/teams/{teamId}', [ - 'teamId' => $teamId - ]) - ); - - return new TeamSquadCollection($response); - } - - /** - * @throws Exception - * @throws ApiErrorException - */ - public function getAllExtendedByTeamId(int $teamId): PlayerCollection - { - $response = $this->sendRequest( - method: 'GET', - path: $this->formatPath('/v3/football/squads/teams/{teamId}/extended', [ - 'teamId' => $teamId - ]) - ); - - return new PlayerCollection($response); - } - - /** - * @throws Exception - * @throws ApiErrorException - */ - public function getAllBySeasonIdAndTeamId(int $seasonId, int $teamId): TeamSquadCollection - { - $response = $this->sendRequest( - method: 'GET', - path: $this->formatPath('/v3/football/squads/seasons/{seasonId}/teams/{teamId}', [ - 'seasonId' => $seasonId, - 'teamId' => $teamId - ]) - ); - - return new TeamSquadCollection($response); - } -} \ No newline at end of file diff --git a/src/Entity/Fixture.php b/src/Entity/Fixture.php index 3d33c0c..5d4f10f 100644 --- a/src/Entity/Fixture.php +++ b/src/Entity/Fixture.php @@ -30,7 +30,7 @@ class Fixture private ?string $name; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; private ?string $resultInfo; @@ -123,7 +123,7 @@ public function __construct(array $data, string $timezone) // select $this->name = $data['name'] ?? null; - $this->startingAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at'], new \DateTimeZone($timezone)) : null; + $this->startAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at'], new \DateTimeZone($timezone)) : null; $this->resultInfo = $data['result_info'] ?? null; $this->leg = $data['leg'] ?? null; $this->details = $data['details'] ?? null; @@ -216,9 +216,9 @@ public function getName(): ?string return $this->name; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } public function getResultInfo(): ?string diff --git a/src/Entity/Group.php b/src/Entity/Group.php index 652e90a..86cff9b 100644 --- a/src/Entity/Group.php +++ b/src/Entity/Group.php @@ -16,9 +16,9 @@ class Group private ?string $name; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endingAt; + private ?\DateTimeImmutable $endAt; private ?bool $hasGamesInCurrentWeek; @@ -37,8 +37,8 @@ public function __construct(array $data) $this->stageId = $data['stage_id']; $this->name = $data['name'] ?? null; - $this->startingAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; - $this->endingAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; + $this->startAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; + $this->endAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; $this->hasGamesInCurrentWeek = $data['games_in_current_week'] ?? null; $this->isCurrent = $data['is_current'] ?? null; $this->hasFinished = $data['finished'] ?? null; @@ -75,14 +75,14 @@ public function getName(): ?string return $this->name; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } - public function getEndingAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endingAt; + return $this->endAt; } public function hasGamesInCurrentWeek(): ?bool diff --git a/src/Entity/Period.php b/src/Entity/Period.php index f4552cd..7758412 100644 --- a/src/Entity/Period.php +++ b/src/Entity/Period.php @@ -14,9 +14,9 @@ class Period private int $typeId; - private ?\DateTimeImmutable $startedAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endedAt; + private ?\DateTimeImmutable $endAt; private ?int $countsFrom; @@ -57,8 +57,8 @@ public function __construct(array $data, string $timezone) $this->hasTimer = $data['has_timer']; // select - $this->startedAt = isset($data['started']) ? \DateTimeImmutable::createFromFormat('U', $data['started']) : null; - $this->endedAt = isset($data['ended']) ? \DateTimeImmutable::createFromFormat('U', $data['ended']) : null; + $this->startAt = isset($data['started']) ? \DateTimeImmutable::createFromFormat('U', $data['started']) : null; + $this->endAt = isset($data['ended']) ? \DateTimeImmutable::createFromFormat('U', $data['ended']) : null; $this->countsFrom = $data['counts_from'] ?? null; $this->isTicking = $data['ticking'] ?? null; $this->sortOrder = $data['sort_order'] ?? null; @@ -91,14 +91,14 @@ public function getTypeId(): int return $this->typeId; } - public function getStartedAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startedAt; + return $this->startAt; } - public function getEndedAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endedAt; + return $this->endAt; } public function getCountsFrom(): ?int diff --git a/src/Entity/Round.php b/src/Entity/Round.php index 38a3751..b9cd214 100644 --- a/src/Entity/Round.php +++ b/src/Entity/Round.php @@ -24,9 +24,9 @@ class Round private ?bool $isCurrent; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endingAt; + private ?\DateTimeImmutable $endAt; private ?bool $hasGamesInCurrentWeek; @@ -56,8 +56,8 @@ public function __construct(array $data, string $timezone) $this->name = $data['name'] ?? null; $this->hasFinished = $data['finished'] ?? null; $this->isCurrent = $data['is_current'] ?? null; - $this->startingAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; - $this->endingAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; + $this->startAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; + $this->endAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; $this->hasGamesInCurrentWeek = $data['games_in_current_week'] ?? null; // include @@ -109,14 +109,14 @@ public function isCurrent(): ?bool return $this->isCurrent; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } - public function getEndingAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endingAt; + return $this->endAt; } public function hasGamesInCurrentWeek(): ?bool diff --git a/src/Entity/Season.php b/src/Entity/Season.php index a9f444a..3ebf99a 100644 --- a/src/Entity/Season.php +++ b/src/Entity/Season.php @@ -24,9 +24,9 @@ class Season private ?bool $isCurrent; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endingAt; + private ?\DateTimeImmutable $endAt; private ?\DateTimeImmutable $standingsRecalculatedAt; @@ -68,8 +68,8 @@ public function __construct(array $data, string $timezone) $this->hasFinished = $data['finished'] ?? null; $this->isPending = $data['pending'] ?? null; $this->isCurrent = $data['is_current'] ?? null; - $this->startingAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; - $this->endingAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; + $this->startAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; + $this->endAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; $this->standingsRecalculatedAt = isset($data['standings_recalculated_at']) ? new \DateTimeImmutable($data['standings_recalculated_at']) : null; $this->hasGamesInCurrentWeek = $data['games_in_current_week'] ?? null; @@ -125,14 +125,14 @@ public function isCurrent(): ?bool return $this->isCurrent; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } - public function getEndingAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endingAt; + return $this->endAt; } public function getStandingsRecalculatedAt(): ?\DateTimeImmutable diff --git a/src/Entity/Sidelined.php b/src/Entity/Sidelined.php index 7c184ac..b306ed1 100644 --- a/src/Entity/Sidelined.php +++ b/src/Entity/Sidelined.php @@ -16,9 +16,9 @@ class Sidelined private ?string $category; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endingAt; + private ?\DateTimeImmutable $endAt; private ?int $gamesMissed; @@ -42,8 +42,8 @@ public function __construct(array $data, string $timezone) // select $this->category = $data['category'] ?? null; - $this->startingAt = isset($data['start_date']) ? new \DateTimeImmutable($data['start_date']) : null; - $this->endingAt = isset($data['end_date']) ? new \DateTimeImmutable($data['end_date']) : null; + $this->startAt = isset($data['start_date']) ? new \DateTimeImmutable($data['start_date']) : null; + $this->endAt = isset($data['end_date']) ? new \DateTimeImmutable($data['end_date']) : null; $this->gamesMissed = $data['games_missed'] ?? null; $this->isCompleted = $data['completed']; @@ -84,14 +84,14 @@ public function getCategory(): ?string return $this->category; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } - public function getEndingAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endingAt; + return $this->endAt; } public function getGamesMissed(): ?int diff --git a/src/Entity/Stage.php b/src/Entity/Stage.php index 6112f22..3d25f91 100644 --- a/src/Entity/Stage.php +++ b/src/Entity/Stage.php @@ -26,9 +26,9 @@ class Stage private ?bool $isCurrent; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endingAt; + private ?\DateTimeImmutable $endAt; private ?bool $hasGamesInCurrentWeek; @@ -75,8 +75,8 @@ public function __construct(array $data, string $timezone) $this->sortOrder = $data['sort_order'] ?? null; $this->hasFinished = $data['finished'] ?? null; $this->isCurrent = $data['is_current'] ?? null; - $this->startingAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; - $this->endingAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; + $this->startAt = isset($data['starting_at']) ? new \DateTimeImmutable($data['starting_at']) : null; + $this->endAt = isset($data['ending_at']) ? new \DateTimeImmutable($data['ending_at']) : null; $this->hasGamesInCurrentWeek = $data['games_in_current_week'] ?? null; $this->tieBreakerRuleId = $data['tie_breaker_rule_id'] ?? null; @@ -139,14 +139,14 @@ public function isCurrent(): ?bool return $this->isCurrent; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } - public function getEndingAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endingAt; + return $this->endAt; } public function hasGamesInCurrentWeek(): ?bool diff --git a/src/Entity/TeamCoach.php b/src/Entity/TeamCoach.php index 0183285..0dd736b 100644 --- a/src/Entity/TeamCoach.php +++ b/src/Entity/TeamCoach.php @@ -14,9 +14,9 @@ class TeamCoach private ?bool $isActive; - private ?\DateTimeImmutable $startedAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endedAt; + private ?\DateTimeImmutable $endAt; private ?bool $isTemporary; @@ -35,8 +35,8 @@ public function __construct(array $data, string $timezone) // select $this->isActive = $data['active'] ?? null; - $this->startedAt = isset($data['start']) ? new \DateTimeImmutable($data['start']) : null; - $this->endedAt = isset($data['end']) ? new \DateTimeImmutable($data['end']) : null; + $this->startAt = isset($data['start']) ? new \DateTimeImmutable($data['start']) : null; + $this->endAt = isset($data['end']) ? new \DateTimeImmutable($data['end']) : null; $this->isTemporary = $data['temporary'] ?? null; // include @@ -70,14 +70,14 @@ public function isActive(): ?bool return $this->isActive; } - public function getStartedAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startedAt; + return $this->startAt; } - public function getEndedAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endedAt; + return $this->endAt; } public function isTemporary(): ?bool diff --git a/src/Entity/TeamSquad.php b/src/Entity/TeamSquad.php index d002e30..81495c2 100644 --- a/src/Entity/TeamSquad.php +++ b/src/Entity/TeamSquad.php @@ -16,9 +16,9 @@ class TeamSquad private ?int $detailedPositionId; - private ?\DateTimeImmutable $startingAt; + private ?\DateTimeImmutable $startAt; - private ?\DateTimeImmutable $endingAt; + private ?\DateTimeImmutable $endAt; private ?bool $isCaptain; @@ -44,8 +44,8 @@ public function __construct(array $data, string $timezone) $this->detailedPositionId = $data['detailed_position_id'] ?? null; // select - $this->startingAt = isset($data['start']) ? new \DateTimeImmutable($data['start']) : null; - $this->endingAt = isset($data['end']) ? new \DateTimeImmutable($data['end']) : null; + $this->startAt = isset($data['start']) ? new \DateTimeImmutable($data['start']) : null; + $this->endAt = isset($data['end']) ? new \DateTimeImmutable($data['end']) : null; $this->isCaptain = $data['captain'] ?? null; $this->jerseyNumber = $data['jersey_number'] ?? null; @@ -87,14 +87,14 @@ public function getDetailedPositionId(): ?int return $this->detailedPositionId; } - public function getStartingAt(): ?\DateTimeImmutable + public function getStartAt(): ?\DateTimeImmutable { - return $this->startingAt; + return $this->startAt; } - public function getEndingAt(): ?\DateTimeImmutable + public function getEndAt(): ?\DateTimeImmutable { - return $this->endingAt; + return $this->endAt; } public function isCaptain(): ?bool diff --git a/src/Resource/TeamSquadResource.php b/src/Resource/TeamSquadResource.php new file mode 100644 index 0000000..977e45d --- /dev/null +++ b/src/Resource/TeamSquadResource.php @@ -0,0 +1,59 @@ +api->request( + method: 'GET', + path: $this->api->buildPath('/v3/football/squads/teams/{teamId}', [ + 'teamId' => $teamId + ]) + ); + + return new TeamSquadCollection($data); + } + + /** + * @throws ClientExceptionInterface + */ + public function getAllExtendedByTeamId(int $teamId): PlayerCollection + { + $data = $this->api->request( + method: 'GET', + path: $this->api->buildPath('/v3/football/squads/teams/{teamId}/extended', [ + 'teamId' => $teamId + ]) + ); + + return new PlayerCollection($data); + } + + /** + * @throws ClientExceptionInterface + */ + public function getAllBySeasonIdAndTeamId(int $seasonId, int $teamId): TeamSquadCollection + { + $data = $this->api->request( + method: 'GET', + path: $this->api->buildPath('/v3/football/squads/seasons/{seasonId}/teams/{teamId}', [ + 'seasonId' => $seasonId, + 'teamId' => $teamId + ]) + ); + + return new TeamSquadCollection($data); + } +} \ No newline at end of file diff --git a/src/SportMonksFootball.php b/src/SportMonksFootball.php index cd01ee6..f9c150a 100644 --- a/src/SportMonksFootball.php +++ b/src/SportMonksFootball.php @@ -50,6 +50,7 @@ use ProgrammatorDev\SportMonksFootball\Resource\StateResource; use ProgrammatorDev\SportMonksFootball\Resource\StatisticResource; use ProgrammatorDev\SportMonksFootball\Resource\TeamResource; +use ProgrammatorDev\SportMonksFootball\Resource\TeamSquadResource; class SportMonksFootball extends Api { @@ -186,11 +187,11 @@ public function teams(): TeamResource return new TeamResource($this); } -// public function teamSquads(): TeamSquadEndpoint -// { -// return new TeamSquadEndpoint($this); -// } -// + public function teamSquads(): TeamSquadResource + { + return new TeamSquadResource($this); + } + // public function timezones(): TimezoneEndpoint // { // return new TimezoneEndpoint($this); diff --git a/tests/Integration/SportMonksFootballTest.php b/tests/Integration/SportMonksFootballTest.php index 9973c2d..71efaf7 100644 --- a/tests/Integration/SportMonksFootballTest.php +++ b/tests/Integration/SportMonksFootballTest.php @@ -26,6 +26,7 @@ use ProgrammatorDev\SportMonksFootball\Resource\StateResource; use ProgrammatorDev\SportMonksFootball\Resource\StatisticResource; use ProgrammatorDev\SportMonksFootball\Resource\TeamResource; +use ProgrammatorDev\SportMonksFootball\Resource\TeamSquadResource; use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; class SportMonksFootballTest extends AbstractTest @@ -56,5 +57,6 @@ public function testMethods() $this->assertInstanceOf(StateResource::class, $this->api->states()); $this->assertInstanceOf(StatisticResource::class, $this->api->statistics()); $this->assertInstanceOf(TeamResource::class, $this->api->teams()); + $this->assertInstanceOf(TeamSquadResource::class, $this->api->teamSquads()); } } \ No newline at end of file diff --git a/tests/Integration/TeamSquadResourceTest.php b/tests/Integration/TeamSquadResourceTest.php new file mode 100644 index 0000000..db67d63 --- /dev/null +++ b/tests/Integration/TeamSquadResourceTest.php @@ -0,0 +1,39 @@ + [ + TeamSquadCollection::class, + MockResponse::TEAM_SQUAD_COLLECTION_DATA, + 'teamSquads', + 'getAllByTeamId', + [1] + ]; + yield 'get all extended by team id' => [ + PlayerCollection::class, + MockResponse::PLAYER_COLLECTION_DATA, + 'teamSquads', + 'getAllExtendedByTeamId', + [1] + ]; + yield 'get all by season id and team id' => [ + TeamSquadCollection::class, + MockResponse::TEAM_SQUAD_COLLECTION_DATA, + 'teamSquads', + 'getAllBySeasonIdAndTeamId', + [1, 1] + ]; + } +} \ No newline at end of file diff --git a/tests/TeamSquadEndpointTest_.php b/tests/TeamSquadEndpointTest_.php deleted file mode 100644 index 6adbb41..0000000 --- a/tests/TeamSquadEndpointTest_.php +++ /dev/null @@ -1,74 +0,0 @@ - [ - MockResponse::TEAM_SQUAD_COLLECTION_DATA, - 'teamSquads', - 'getAllByTeamId', - [1], - 'assertTeamSquadResponse' - ]; - yield 'get all extended by team id' => [ - MockResponse::PLAYER_COLLECTION_DATA, - 'teamSquads', - 'getAllExtendedByTeamId', - [1], - 'assertPlayerResponse' - ]; - yield 'get all by season id and team id' => [ - MockResponse::TEAM_SQUAD_COLLECTION_DATA, - 'teamSquads', - 'getAllBySeasonIdAndTeamId', - [1, 1], - 'assertTeamSquadResponse' - ]; - } - - private function assertTeamSquadResponse(TeamSquad $teamSquad): void - { - $this->assertSame(741301, $teamSquad->getId()); - $this->assertSame(233006, $teamSquad->getTransferId()); - $this->assertSame(8056287, $teamSquad->getPlayerId()); - $this->assertSame(53, $teamSquad->getTeamId()); - $this->assertSame(25, $teamSquad->getPositionId()); - $this->assertSame(148, $teamSquad->getDetailedPositionId()); - $this->assertSame('2023-07-26 00:00:00', $teamSquad->getStartingAt()->format('Y-m-d H:i:s')); - $this->assertSame('2028-05-31 00:00:00', $teamSquad->getEndingAt()->format('Y-m-d H:i:s')); - $this->assertSame(false, $teamSquad->isCaptain()); - $this->assertSame(17, $teamSquad->getJerseyNumber()); - } - - private function assertPlayerResponse(Player $player): void - { - $this->assertSame(14, $player->getId()); - $this->assertSame(1, $player->getSportId()); - $this->assertSame(320, $player->getCountryId()); - $this->assertSame(320, $player->getNationalityId()); - $this->assertSame(null, $player->getCityId()); - $this->assertSame(25, $player->getPositionId()); - $this->assertSame(null, $player->getDetailedPositionId()); - $this->assertSame(25, $player->getTypeId()); - $this->assertSame('D. Agger', $player->getCommonName()); - $this->assertSame('Daniel Munthe', $player->getFirstName()); - $this->assertSame('Agger', $player->getLastName()); - $this->assertSame('Daniel Munthe Agger', $player->getName()); - $this->assertSame('Daniel Agger', $player->getDisplayName()); - $this->assertSame('https://cdn.sportmonks.com/images/soccer/players/14/14.png', $player->getImagePath()); - $this->assertSame(191, $player->getHeight()); - $this->assertSame(84, $player->getWeight()); - $this->assertSame('1984-12-12 00:00:00', $player->getDateOfBirth()->format('Y-m-d H:i:s')); - $this->assertSame('male', $player->getGender()); - $this->assertSame(true, $player->inSquad()); - } -} \ No newline at end of file diff --git a/tests/Unit/FixtureTest.php b/tests/Unit/FixtureTest.php index 5a3edb7..fffcbe3 100644 --- a/tests/Unit/FixtureTest.php +++ b/tests/Unit/FixtureTest.php @@ -42,7 +42,7 @@ public function testMethods(): void $this->assertSame(1, $entity->getStateId()); $this->assertSame(1, $entity->getVenueId()); $this->assertSame('name', $entity->getName()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartingAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); $this->assertSame('result info', $entity->getResultInfo()); $this->assertSame('leg', $entity->getLeg()); $this->assertSame('details', $entity->getDetails()); diff --git a/tests/Unit/GroupTest.php b/tests/Unit/GroupTest.php index ca338a7..f9c27f7 100644 --- a/tests/Unit/GroupTest.php +++ b/tests/Unit/GroupTest.php @@ -30,8 +30,8 @@ public function testMethods(): void $this->assertSame(1, $entity->getSeasonId()); $this->assertSame(1, $entity->getStageId()); $this->assertSame('name', $entity->getName()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartingAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndingAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertSame(false, $entity->hasGamesInCurrentWeek()); $this->assertSame(false, $entity->isCurrent()); $this->assertSame(false, $entity->hasFinished()); diff --git a/tests/Unit/PeriodTest.php b/tests/Unit/PeriodTest.php index 31fa7b7..263ffea 100644 --- a/tests/Unit/PeriodTest.php +++ b/tests/Unit/PeriodTest.php @@ -30,8 +30,8 @@ public function testMethods(): void $this->assertSame(1, $entity->getFixtureId()); $this->assertSame(1, $entity->getTypeId()); $this->assertSame(false, $entity->hasTimer()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartedAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndedAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertSame(0, $entity->getCountsFrom()); $this->assertSame(false, $entity->isTicking()); $this->assertSame(1, $entity->getSortOrder()); diff --git a/tests/Unit/RoundTest.php b/tests/Unit/RoundTest.php index 2e675c3..c4ce283 100644 --- a/tests/Unit/RoundTest.php +++ b/tests/Unit/RoundTest.php @@ -31,8 +31,8 @@ public function testMethods(): void $this->assertSame('name', $entity->getName()); $this->assertSame(true, $entity->hasFinished()); $this->assertSame(false, $entity->isCurrent()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartingAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndingAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertSame(false, $entity->hasGamesInCurrentWeek()); } } \ No newline at end of file diff --git a/tests/Unit/SeasonTest.php b/tests/Unit/SeasonTest.php index 5b9f699..a0ef90b 100644 --- a/tests/Unit/SeasonTest.php +++ b/tests/Unit/SeasonTest.php @@ -32,8 +32,8 @@ public function testMethods(): void $this->assertSame(true, $entity->hasFinished()); $this->assertSame(false, $entity->isPending()); $this->assertSame(false, $entity->isCurrent()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartingAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndingAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStandingsRecalculatedAt()); $this->assertSame(false, $entity->hasGamesInCurrentWeek()); } diff --git a/tests/Unit/SidelinedTest.php b/tests/Unit/SidelinedTest.php index e6129ec..0443ab3 100644 --- a/tests/Unit/SidelinedTest.php +++ b/tests/Unit/SidelinedTest.php @@ -28,8 +28,8 @@ public function testMethods(): void $this->assertSame(1, $entity->getTeamId()); $this->assertSame(1, $entity->getSeasonId()); $this->assertSame('injury', $entity->getCategory()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartingAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndingAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertSame(2, $entity->getGamesMissed()); $this->assertSame(true, $entity->isCompleted()); } diff --git a/tests/Unit/StageTest.php b/tests/Unit/StageTest.php index 8f718f4..abe0b9a 100644 --- a/tests/Unit/StageTest.php +++ b/tests/Unit/StageTest.php @@ -34,8 +34,8 @@ public function testMethods(): void $this->assertSame(1, $entity->getSortOrder()); $this->assertSame(true, $entity->hasFinished()); $this->assertSame(false, $entity->isCurrent()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartingAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndingAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertSame(false, $entity->hasGamesInCurrentWeek()); $this->assertSame(1, $entity->getTieBreakerRuleId()); } diff --git a/tests/Unit/TeamCoachTest.php b/tests/Unit/TeamCoachTest.php index 10c3240..3512801 100644 --- a/tests/Unit/TeamCoachTest.php +++ b/tests/Unit/TeamCoachTest.php @@ -25,8 +25,8 @@ public function testMethods(): void $this->assertSame(1, $entity->getCoachId()); $this->assertSame(1, $entity->getPositionId()); $this->assertSame(false, $entity->isActive()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartedAt()); - $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndedAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); $this->assertSame(false, $entity->isTemporary()); } } \ No newline at end of file diff --git a/tests/Unit/TeamSquadTest.php b/tests/Unit/TeamSquadTest.php new file mode 100644 index 0000000..4bb7dc6 --- /dev/null +++ b/tests/Unit/TeamSquadTest.php @@ -0,0 +1,36 @@ + 1, + 'transfer_id' => 1, + 'player_id' => 1, + 'team_id' => 1, + 'position_id' => 1, + 'detailed_position_id' => 1, + 'start' => '2024-01-01', + 'end' => '2024-01-07', + 'captain' => false, + 'jersey_number' => 1 + ], 'UTC'); + + $this->assertSame(1, $entity->getId()); + $this->assertSame(1, $entity->getTransferId()); + $this->assertSame(1, $entity->getPlayerId()); + $this->assertSame(1, $entity->getTeamId()); + $this->assertSame(1, $entity->getPositionId()); + $this->assertSame(1, $entity->getDetailedPositionId()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getStartAt()); + $this->assertInstanceOf(\DateTimeImmutable::class, $entity->getEndAt()); + $this->assertSame(false, $entity->isCaptain()); + $this->assertSame(1, $entity->getJerseyNumber()); + } +} \ No newline at end of file