Skip to content

Commit

Permalink
refactor: Ensure it’s an array
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 29, 2024
1 parent 6f9f574 commit 021af98
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/services/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ public function fetchFieldDataByCantoId(string $cantoId): ?CantoFieldData
}

return new CantoFieldData([
'cantoId' => $responseBody['id'] ?: 0,
'cantoId' => $responseBody['id'],
'cantoAlbumId' => 0,
'cantoAssetData' => [$responseBody],
'cantoAlbumData' => [
'id' => $responseBody['relatedAlbums'][0]['id'] ?: 0,
'name' => $responseBody['relatedAlbums'][0]['name'] ?: '',
'id' => $responseBody['relatedAlbums'][0]['id'],

Check failure on line 118 in src/services/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Offset 'id' does not exist on string.
'name' => $responseBody['relatedAlbums'][0]['name'],

Check failure on line 119 in src/services/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Offset 'name' does not exist on string.
],
]);
}
Expand Down Expand Up @@ -166,6 +166,9 @@ public function paginatedAlbumRequest(array &$buffer, string $albumId, int $star
if (isset($responseBody['status']) && $responseBody['status'] === 'error') {
return false;
}
if (!is_array($responseBody['results'])) {

Check failure on line 169 in src/services/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to function is_array() with string will always evaluate to false.
return false;
}
$buffer = array_merge($buffer, $responseBody['results']);

Check failure on line 172 in src/services/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Unreachable statement - code above always terminates.
if (count($buffer) < $responseBody['found']) {
$this->paginatedAlbumRequest($buffer, $albumId, $start + self::MAX_ALBUM_REQUEST_ITEMS);
Expand Down

0 comments on commit 021af98

Please sign in to comment.