Passed
Push — master ( ef2d88...898186 )
by Arthur
06:43
created

MachineTransformer::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 1
nop 1
dl 0
loc 21
rs 9.6333
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 29.10.18
6
 * Time: 09:38
7
 */
8
9
namespace Modules\Machine\Transformer;
10
11
12
use Foundation\Abstracts\Transformers\Transformer;
13
use Modules\User\Entities\User;
14
use Modules\User\Transformers\UserTransformer;
15
16
class MachineTransformer extends Transformer
17
{
18
    public $relations = [
19
        'user'
20
    ];
21
22
    /**
23
     * Transform the resource into an array.
24
     *
25
     * @param \Illuminate\Http\Request $request
26
     *
27
     * @return array
28
     */
29
    public function toArray($request)
30
    {
31
        return [
32
            'id' => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
            'user_id' => $this->user_id,
0 ignored issues
show
Bug Best Practice introduced by
The property user_id does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
34
            'name' => $this->name,
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
35
            'hostname' => $this->hostname,
0 ignored issues
show
Bug Best Practice introduced by
The property hostname does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
36
            'username' => $this->username,
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
            'os' => $this->os,
0 ignored issues
show
Bug Best Practice introduced by
The property os does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
38
            'hash' => $this->hash,
0 ignored issues
show
Bug Best Practice introduced by
The property hash does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
39
            'active' => $this->active,
0 ignored issues
show
Bug Best Practice introduced by
The property active does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
40
            'ip_address' => $this->ip_address,
0 ignored issues
show
Bug Best Practice introduced by
The property ip_address does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
41
            'mac_address' => $this->mac_address,
0 ignored issues
show
Bug Best Practice introduced by
The property mac_address does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
            'memory_usage' => $this->memory_usage,
0 ignored issues
show
Bug Best Practice introduced by
The property memory_usage does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
            'memory_available' => $this->memory_available,
0 ignored issues
show
Bug Best Practice introduced by
The property memory_available does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
44
            'cpu_usage' => $this->cpu_usage,
0 ignored issues
show
Bug Best Practice introduced by
The property cpu_usage does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
45
            'cpu_clock' => 5,
46
            'online' => true,
47
            'last_heartbeat' => $this->last_heartbeat ?? null,
0 ignored issues
show
Bug Best Practice introduced by
The property last_heartbeat does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
48
            'created_at' => $this->created_at,
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
49
            'updated_at' => $this->updated_at,
0 ignored issues
show
Bug Best Practice introduced by
The property updated_at does not exist on Modules\Machine\Transformer\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
50
        ];
51
    }
52
53
    public function transformUser(User $user)
54
    {
55
        return UserTransformer::resource($user);
56
    }
57
58
}
59