Passed
Push — master ( 7bc374...cf39f3 )
by Arthur
05:05
created

MachineResource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 21 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 15.10.18
6
 * Time: 23:21.
7
 */
8
9
namespace Modules\Machine\Resources;
10
11
use Carbon\Carbon;
12
use Illuminate\Http\Resources\Json\JsonResource;
13
14
class MachineResource extends JsonResource
15
{
16
    /**
17
     * Transform the resource into an array.
18
     *
19
     * @param \Illuminate\Http\Request $request
20
     *
21
     * @return array
22
     */
23
    public function toArray($request)
24
    {
25
        return [
26
            'id'               => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
27
            'user_id'          => $this->user_id,
0 ignored issues
show
Bug Best Practice introduced by
The property user_id does not exist on Modules\Machine\Resources\MachineResource. 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\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
            'hostname'         => $this->hostname,
0 ignored issues
show
Bug Best Practice introduced by
The property hostname does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
30
            'username'         => $this->username,
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
31
            'os'               => $this->os,
0 ignored issues
show
Bug Best Practice introduced by
The property os does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
            'hash'             => $this->hash,
0 ignored issues
show
Bug Best Practice introduced by
The property hash does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
            'active'           => $this->active,
0 ignored issues
show
Bug Best Practice introduced by
The property active does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
34
            'ip_address'       => $this->ip_address,
0 ignored issues
show
Bug Best Practice introduced by
The property ip_address does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
35
            'mac_address'      => $this->mac_address,
0 ignored issues
show
Bug Best Practice introduced by
The property mac_address does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
36
            'memory_usage'     => $this->memory_usage,
0 ignored issues
show
Bug Best Practice introduced by
The property memory_usage does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
            'memory_available' => $this->memory_available,
0 ignored issues
show
Bug Best Practice introduced by
The property memory_available does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
38
            'cpu_usage'        => $this->cpu_usage,
0 ignored issues
show
Bug Best Practice introduced by
The property cpu_usage does not exist on Modules\Machine\Resources\MachineResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
39
            'cpu_clock'        => 5,
40
            'online'           => true,
41
            'last_heartbeat'   => Carbon::now()->toDateTimeString(),
42
            'created_at'       => Carbon::now()->toDateTimeString(),
43
            'updated_at'       => Carbon::now()->toDateTimeString(),
44
        ];
45
    }
46
}
47