Completed
Push — main ( e8b4c6...9a4ea9 )
by Tan
16s queued 14s
created

PostNavigateResource::toArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 3
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources\Post;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Http\Resources\Json\JsonResource;
7
8
/**
9
 * Post Navigate Resource for combined previous/next response
10
 */
11
class PostNavigateResource extends JsonResource
12
{
13
    /**
14
     * @param  Request  $request
15
     *
16
     * @return array<string, mixed>
17
     */
18
    public function toArray($request): array
19
    {
20
        return [
21
            'previous' => $this->resource['previous'] ? new PostNavigationResource($this->resource['previous']) : null,
22
            'next' => $this->resource['next'] ? new PostNavigationResource($this->resource['next']) : null,
23
        ];
24
    }
25
}
26