Skip to content

Commit

Permalink
chore: phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
edodusi committed Jan 27, 2025
1 parent 464198d commit e60b104
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/Endpoints/StoryApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class StoryApi extends EndpointSpace
private LoggerInterface $logger;

/**
* StoryApi constructor.
*
* @param HttpClientInterface $httpClient
* @param string|int $spaceId
* @param LoggerInterface|null $logger Optional logger, defaults to NullLogger if not provided
*/
* StoryApi constructor.
*
* @param HttpClientInterface $httpClient
* @param string|int $spaceId
* @param LoggerInterface $logger
*/
public function __construct(
HttpClientInterface $httpClient,
string|int $spaceId,
Expand Down Expand Up @@ -234,13 +234,14 @@ private function handleRateLimit(): void
* Extracts stories from the API response
*
* @param StoryblokResponseInterface $response
* @return \Generator<StoryData>
* @return \Generator<int, StoryData>
*/
private function getStoriesFromResponse(StoryblokResponseInterface $response): \Generator
{
/** @var StoriesData $stories */
$stories = $response->data();
foreach ($stories as $story) {
/** @var StoryData $story */
yield $story;
}
}
Expand All @@ -250,7 +251,7 @@ private function getStoriesFromResponse(StoryblokResponseInterface $response): \
*
* @param int $page
* @param int $perPage
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
private function validatePaginationParams(int $page, int $perPage): void
{
Expand All @@ -266,7 +267,7 @@ private function validatePaginationParams(int $page, int $perPage): void
* Validates story ID
*
* @param string $storyId
* @throws InvalidArgumentException
* @throws \InvalidArgumentException
*/
private function validateStoryId(string $storyId): void
{
Expand Down
8 changes: 6 additions & 2 deletions src/MapiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ public function spaceApi(): SpaceApi
* @param LoggerInterface|null $logger
* @return StoryApi
*/
public function storyApi(string|int $spaceId, ?LoggerInterface $logger = new NullLogger()): StoryApi
public function storyApi(string|int $spaceId, ?LoggerInterface $logger = null): StoryApi
{
return new StoryApi($this->httpClient, $spaceId, $logger);
return new StoryApi(
$this->httpClient,
$spaceId,
$logger ?? new NullLogger(),
);
}

public function userApi(): UserApi
Expand Down

0 comments on commit e60b104

Please sign in to comment.