SermonList::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 12
rs 9.9666
1
<?php
2
3
namespace FaithGen\Sermons\Http\Resources;
4
5
use Carbon\Carbon;
6
use FaithGen\SDK\Helpers\ImageHelper;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
use InnoFlash\LaraStart\Helper;
9
10
class SermonList extends JsonResource
11
{
12
    /**
13
     * Transform the resource into an array.
14
     *
15
     * @param \Illuminate\Http\Request $request
16
     * @return array
17
     */
18
    public function toArray($request)
19
    {
20
        return [
21
            'id' => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on FaithGen\Sermons\Http\Resources\SermonList. Since you implemented __get, consider adding a @property annotation.
Loading history...
22
            'title' => $this->title,
0 ignored issues
show
Bug Best Practice introduced by
The property title does not exist on FaithGen\Sermons\Http\Resources\SermonList. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
            'preacher' => [
24
                'name' => $this->preacher,
0 ignored issues
show
Bug Best Practice introduced by
The property preacher does not exist on FaithGen\Sermons\Http\Resources\SermonList. Since you implemented __get, consider adding a @property annotation.
Loading history...
25
                'avatar' => ImageHelper::getImage('sermons', $this->image, config('faithgen-sdk.ministries-server')),
0 ignored issues
show
Bug Best Practice introduced by
The property image does not exist on FaithGen\Sermons\Http\Resources\SermonList. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
            ],
27
            'date' => Helper::getDates(Carbon::parse($this->date)),
0 ignored issues
show
Bug Best Practice introduced by
The property date does not exist on FaithGen\Sermons\Http\Resources\SermonList. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            'comments' => [
29
                'count' => number_format($this->comments()->count()),
0 ignored issues
show
Bug introduced by
The method comments() does not exist on FaithGen\Sermons\Http\Resources\SermonList. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
                'count' => number_format($this->/** @scrutinizer ignore-call */ comments()->count()),
Loading history...
30
            ],
31
        ];
32
    }
33
}
34