PlayerCensusTransformer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 33
rs 10
c 1
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 23 1
1
<?php
2
3
namespace Ps2alerts\Api\Transformer\Profiles;
4
5
use League\Fractal\TransformerAbstract;
6
7
class PlayerCensusTransformer extends TransformerAbstract
8
{
9
    /**
10
     * The transform method required by Fractal to parse the data and return proper typing and fields.
11
     *
12
     * @param  array $data Data to transform
13
     *
14
     * @return array
15
     */
16
    public function transform($data)
17
    {
18
        return [
19
            'name'           => (string) $data['name']['first'],
20
            'lastOnline'     => (int) $data['times']['last_login'],
21
            'lastOnlineDate' => (string) $data['times']['last_login_date'],
22
            'minutesPlayed'  => (int) $data['times']['minutes_played'],
23
            'certs' => [
24
                'earned'    => (int) $data['certs']['earned_points'],
25
                'spent'     => (int) $data['certs']['spent_points'],
26
                'available' => (int) $data['certs']['available_points'],
27
            ],
28
            'battleRank' => [
29
                'current'       => (int) $data['battle_rank']['value'],
30
                'percentToNext' => (int) $data['battle_rank']['percent_to_next'],
31
            ],
32
            'stats' => [
33
                'kills'     => (int) $data['kills'],
34
                'deaths'    => (int) $data['deaths'],
35
                'headshots' => (int) $data['headshots']
36
            ]
37
        ];
38
    }
39
}
40