Passed
Push — master ( 471523...a46036 )
by Arthur
13:15
created

AccountTransformer::toArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.7085

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 1
dl 0
loc 10
ccs 4
cts 7
cp 0.5714
crap 3.7085
rs 10
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\Account\Transformers;
10
11
use Foundation\Abstracts\Transformers\Transformer;
12
use Foundation\Exceptions\Exception;
13
use Modules\Machine\Transformers\MachineTransformer;
14
use Modules\User\Transformers\UserTransformer;
15
16
class AccountTransformer extends Transformer
17
{
18
    public $available = [
19
        'user' => UserTransformer::class,
20
        'machine' => MachineTransformer::class,
21
    ];
22
23
    /**
24
     * Transform the resource into an array.
25
     *
26
     * @throws Exception
27
     *
28
     * @return array
29
     */
30 6
    public function transformResource()
31
    {
32 6
        $game = $this->game ?? null;
0 ignored issues
show
Bug Best Practice introduced by
The property game does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
        switch ($game) {
34 6
            case 'OSRS':
35 6
                return $this->OSRSAccountToArray();
36
            case null:
37
                return null;
38
            default:
39
                throw new Exception('Could not identity account game type');
40
        }
41
    }
42
43 6
    protected function OSRSAccountToArray()
44
    {
45
        return [
46 6
            'id'                    => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
47 6
            'username'              => $this->username,
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
48 6
            'password'              => $this->password,
0 ignored issues
show
Bug Best Practice introduced by
The property password does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
49 6
            'game'                  => $this->game,
0 ignored issues
show
Bug Best Practice introduced by
The property game does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
50 6
            'bank_pin'              => $this->bank_pin,
0 ignored issues
show
Bug Best Practice introduced by
The property bank_pin does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
51 6
            'location'              => $this->location,
0 ignored issues
show
Bug Best Practice introduced by
The property location does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
52 6
            'ingame_name'           => $this->ingame_name,
0 ignored issues
show
Bug Best Practice introduced by
The property ingame_name does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
53 6
            'skills'                => $this->skills,
0 ignored issues
show
Bug Best Practice introduced by
The property skills does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
54 6
            'membership_expires_at' => $this->membership_expires_at,
0 ignored issues
show
Bug Best Practice introduced by
The property membership_expires_at does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
55 6
            'banned_at'             => $this->banned_at,
0 ignored issues
show
Bug Best Practice introduced by
The property banned_at does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
56 6
            'created_at'            => $this->created_at,
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
57 6
            'updated_at'            => $this->updated_at,
0 ignored issues
show
Bug Best Practice introduced by
The property updated_at does not exist on Modules\Account\Transformers\AccountTransformer. Since you implemented __get, consider adding a @property annotation.
Loading history...
58
        ];
59
    }
60
}
61