Passed
Push — master ( 4c3e72...46eb59 )
by Arthur
10:39
created

MachineTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 40
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transformUser() 0 3 1
A toArray() 0 21 1
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\Transformers;
10
11
use Foundation\Abstracts\Transformers\Transformer;
12
use Modules\Machine\Entities\Machine;
13
use Modules\User\Entities\User;
14
use Modules\User\Transformers\UserTransformer;
15
16
class MachineTransformer extends Transformer
17
{
18
    public $available = [
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 6
    public function toArray($request)
30
    {
31
        return [
32 6
            'id'               => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
33 6
            'user_id'          => $this->user_id,
0 ignored issues
show
Bug Best Practice introduced by
The property user_id does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
34 6
            'name'             => $this->name,
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
35 6
            'hostname'         => $this->hostname,
0 ignored issues
show
Bug Best Practice introduced by
The property hostname does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
36 6
            'username'         => $this->username,
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
37 6
            'os'               => $this->os,
0 ignored issues
show
Bug Best Practice introduced by
The property os does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
38 6
            'hash'             => $this->hash,
0 ignored issues
show
Bug Best Practice introduced by
The property hash does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
39 6
            'active'           => $this->active,
0 ignored issues
show
Bug Best Practice introduced by
The property active does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
40 6
            'ip_address'       => $this->ip_address,
0 ignored issues
show
Bug Best Practice introduced by
The property ip_address does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
41 6
            'mac_address'      => $this->mac_address,
0 ignored issues
show
Bug Best Practice introduced by
The property mac_address does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
42 6
            'memory_usage'     => $this->memory_usage,
0 ignored issues
show
Bug Best Practice introduced by
The property memory_usage does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
43 6
            'memory_available' => $this->memory_available,
0 ignored issues
show
Bug Best Practice introduced by
The property memory_available does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
44 6
            'cpu_usage'        => $this->cpu_usage,
0 ignored issues
show
Bug Best Practice introduced by
The property cpu_usage does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
45 6
            'cpu_clock'        => $this->cpu_clock,
0 ignored issues
show
Bug Best Practice introduced by
The property cpu_clock does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
46 6
            'online'           => $this->online,
0 ignored issues
show
Bug Best Practice introduced by
The property online does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
47 6
            '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\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
48 6
            'created_at'       => $this->created_at,
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
49 6
            'updated_at'       => $this->updated_at,
0 ignored issues
show
Bug Best Practice introduced by
The property updated_at does not exist on Modules\Machine\Transformers\MachineTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
50
        ];
51
    }
52
53 1
    public function transformUser(Machine $machine)
54
    {
55 1
        return UserTransformer::resource($machine->user);
56
    }
57
}
58