Profile::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 1
Metric Value
cc 2
eloc 29
c 4
b 1
f 1
nc 2
nop 1
dl 0
loc 34
rs 9.456
1
<?php
2
3
namespace FaithGen\SDK\Http\Resources;
4
5
use FaithGen\SDK\Helpers\ImageHelper;
6
use Illuminate\Http\Resources\Json\JsonResource;
7
use InnoFlash\LaraStart\Helper;
8
9
class Profile extends JsonResource
10
{
11
    /**
12
     * Transform the resource into an array.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     *
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\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
22
            'name'      => $this->name,
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
            'email'     => $this->email,
0 ignored issues
show
Bug Best Practice introduced by
The property email does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
24
            'phone'     => $this->phone,
0 ignored issues
show
Bug Best Practice introduced by
The property phone does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
25
            'color'     => $this->profile->color,
0 ignored issues
show
Bug Best Practice introduced by
The property profile does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
            'active'    => (bool) $this->activation->active,
0 ignored issues
show
Bug Best Practice introduced by
The property activation does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
27
            'api_key'   => $this->apiKey->api_key,
0 ignored issues
show
Bug Best Practice introduced by
The property apiKey does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            'avatar'    => ImageHelper::getImage('profile', $this->image, config('faithgen-sdk.ministries-server')),
0 ignored issues
show
Bug Best Practice introduced by
The property image does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
            'date'      => Helper::getDates($this->created_at),
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
30
            'users'     => [
31
                'count' => $this->ministryUsers()->count(),
0 ignored issues
show
Bug introduced by
The method ministryUsers() does not exist on FaithGen\SDK\Http\Resources\Profile. 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

31
                'count' => $this->/** @scrutinizer ignore-call */ ministryUsers()->count(),
Loading history...
32
            ],
33
            'location'  => is_array($this->profile->location)
34
                ? $this->profile->location
35
                : json_decode($this->profile->location),
36
            'links'     => [
37
                'website'   => $this->profile->website,
38
                'facebook'  => $this->profile->facebook,
39
                'youtube'   => $this->profile->youtube,
40
                'twitter'   => $this->profile->twitter,
41
                'instagram' => $this->profile->instagram,
42
            ],
43
            'contact'   => [
44
                'phones' => $this->phones,
0 ignored issues
show
Bug Best Practice introduced by
The property phones does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
45
                'emails' => $this->emails,
0 ignored issues
show
Bug Best Practice introduced by
The property emails does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
46
            ],
47
            'services'  => DailyService::collection($this->services),
0 ignored issues
show
Bug Best Practice introduced by
The property services does not exist on FaithGen\SDK\Http\Resources\Profile. Since you implemented __get, consider adding a @property annotation.
Loading history...
48
            'statement' => [
49
                'vision'   => $this->profile->vision,
50
                'mission'  => $this->profile->mission,
51
                'about_us' => $this->profile->about_us,
52
            ],
53
        ];
54
    }
55
}
56