ActivityResource   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 15 2
1
<?php
2
3
namespace App\Http\Resources;
4
5
use App\Models\Stage;
6
use Illuminate\Http\Resources\Json\JsonResource;
7
8
class ActivityResource extends JsonResource
9
{
10
    /**
11
     * Transform the resource into an array.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     *
15
     * @return array
16
     */
17
    public function toArray($request)
18
    {
19
        $valueText = $this->new_value;
0 ignored issues
show
Bug Best Practice introduced by
The property new_value does not exist on App\Http\Resources\ActivityResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
20
        if ($this->type === Stage::class) {
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist on App\Http\Resources\ActivityResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
21
            $valueText = Stage::find($this->new_value)->name;
22
        }
23
24
        return [
25
            'created_at'     => $this->created_at,
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on App\Http\Resources\ActivityResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
            'type'           => $this->type,
27
            'prev_value'     => $this->prev_value,
0 ignored issues
show
Bug Best Practice introduced by
The property prev_value does not exist on App\Http\Resources\ActivityResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            'new_value'      => $this->new_value,
29
            'new_value_text' => $valueText,
30
            'user'           => [
31
                'name' => $this->user->name,
0 ignored issues
show
Bug Best Practice introduced by
The property user does not exist on App\Http\Resources\ActivityResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
            ],
33
        ];
34
    }
35
}
36