Passed
Push — master ( f51c1b...16736d )
by Arthur
05:36
created

UserResource::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 13
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 15.10.18
6
 * Time: 23:21.
7
 */
8
9
namespace Modules\User\Resources;
10
11
use Illuminate\Http\Resources\Json\JsonResource;
12
use Modules\Authorization\Resources\PermissionResource;
13
use Modules\Authorization\Resources\RoleResource;
14
15
class UserResource extends JsonResource
16
{
17
    /**
18
     * Transform the resource into an array.
19
     *
20
     * @param \Illuminate\Http\Request $request
21
     *
22
     * @return array
23
     */
24
    public function toArray($request)
25
    {
26
        return [
27
            'id'               => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            'name'             => $this->name,
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
            'email'            => $this->name,
30
            'email_verified'   => $this->email_verified,
0 ignored issues
show
Bug Best Practice introduced by
The property email_verified does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
31
            'gender'           => $this->gender,
0 ignored issues
show
Bug Best Practice introduced by
The property gender does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
            'provider'         => $this->provider,
0 ignored issues
show
Bug Best Practice introduced by
The property provider does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
            'created_at'       => $this->created_at,
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
34
            'updated_at'       => $this->updated_at,
0 ignored issues
show
Bug Best Practice introduced by
The property updated_at does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
35
            'roles'            => collect(RoleResource::collection($this->roles)->toArray(null))->flatten(),
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist on Modules\User\Resources\UserResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
36
            'permissions'      => collect(PermissionResource::collection($this->getAllPermissions() )->toArray(null))->flatten()
0 ignored issues
show
Bug introduced by
The method getAllPermissions() does not exist on Modules\User\Resources\UserResource. 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

36
            'permissions'      => collect(PermissionResource::collection($this->/** @scrutinizer ignore-call */ getAllPermissions() )->toArray(null))->flatten()
Loading history...
37
        ];
38
    }
39
}
40