Skip to content

Commit 68ef105

Browse files
committed
feat: enhance post navigation resource and service with type annotations
1 parent d9d27f2 commit 68ef105

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Http/Resources/Post/PostNavigateResource.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ class PostNavigateResource extends JsonResource
1717
*/
1818
public function toArray($request): array
1919
{
20+
/** @var array{previous: object|null, next: object|null} $resource */
21+
$resource = $this->resource;
22+
2023
return [
21-
'previous' => $this->resource['previous'] ? new PostNavigationResource($this->resource['previous']) : null,
22-
'next' => $this->resource['next'] ? new PostNavigationResource($this->resource['next']) : null,
24+
'previous' => $resource['previous'] ? new PostNavigationResource($resource['previous']) : null,
25+
'next' => $resource['next'] ? new PostNavigationResource($resource['next']) : null,
2326
];
2427
}
2528
}

src/Services/PostNavigationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getNextPost(int|string $postId): ?object
4545
* Get both previous and next posts
4646
*
4747
* @param int|string $postId
48-
* @return array
48+
* @return array{previous: object|null, next: object|null}
4949
*/
5050
public function getNavigatePosts(int|string $postId): array
5151
{

0 commit comments

Comments
 (0)