ViewCountResource::toArray()   A
last analyzed

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\Request;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
9
/**
10
 * @mixin Post
11
 */
12
class ViewCountResource extends JsonResource
13
{
14
    /**
15
     * @param  Request  $request
16
     *
17
     * @return array<string, mixed>
18
     */
19
    public function toArray(Request $request): array
20
    {
21
        /** @var Post $this */
22
        return [
23
            'id' => $this->id,
24
            'views' => number_format($this->views),
25
        ];
26
    }
27
}
28