AccountTransformer::transformResource()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 1
dl 0
loc 10
ccs 0
cts 10
cp 0
crap 12
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\Account\Entities\Account;
14
use Modules\Machine\Transformers\MachineTransformer;
15
use Modules\User\Transformers\UserTransformer;
16
17
class AccountTransformer extends Transformer
18
{
19
    public $available = [
20
        'user'    => UserTransformer::class,
21
        'machine' => MachineTransformer::class,
22
    ];
23
24
    /**
25
     * Transform the resource into an array.
26
     *
27
     * @throws Exception
28
     *
29
     * @return array
30
     */
31
    public function transformResource(Account $app)
32
    {
33
        $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...
34
        switch ($game) {
35
            case 'OSRS':
36
                return $this->OSRSAccountToArray($app);
37
            case null:
38
                return;
39
            default:
40
                throw new Exception('Could not identity account game type');
41
        }
42
    }
43
44
    protected function OSRSAccountToArray(Account $account)
45
    {
46
        return [
47
            'id'                    => $account->id,
48
            'username'              => $account->username,
0 ignored issues
show
Bug introduced by
The property username does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
49
            'password'              => $account->password,
0 ignored issues
show
Bug introduced by
The property password does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
50
            'game'                  => $account->game,
0 ignored issues
show
Bug introduced by
The property game does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
51
            'bank_pin'              => $account->bank_pin,
0 ignored issues
show
Bug introduced by
The property bank_pin does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
52
            'location'              => $account->location,
0 ignored issues
show
Bug introduced by
The property location does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
53
            'ingame_name'           => $account->ingame_name,
0 ignored issues
show
Bug introduced by
The property ingame_name does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
54
            'skills'                => $account->skills,
0 ignored issues
show
Bug introduced by
The property skills does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
55
            'membership_expires_at' => $account->membership_expires_at,
0 ignored issues
show
Bug introduced by
The property membership_expires_at does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
56
            'banned_at'             => $account->banned_at,
0 ignored issues
show
Bug introduced by
The property banned_at does not seem to exist on Modules\Account\Entities\Account. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
57
            'created_at'            => $account->created_at,
58
            'updated_at'            => $account->updated_at,
59
        ];
60
    }
61
}
62