Passed
Pull Request — main (#62)
by Tan
03:17
created

ViewCountResource::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources\Post;
4
5
use CSlant\Blog\Core\Models\Post;
6
use Illuminate\Http\Resources\Json\JsonResource;
7
8
/**
9
 * @mixin Post
10
 */
11
class ViewCountResource extends JsonResource
12
{
13
    /**
14
     * @param $request
15
     *
16
     * @return array<string, mixed>
17
     */
18
    public function toArray($request): array
19
    {
20
        /** @var Post $this */
21
        return [
22
            'id' => $this->id,
23
            'views' => number_format((int) $this->views),
24
        ];
25
    }
26
}
27