CharacterTransformer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 19 2
1
<?php
2
3
namespace Ps2alerts\Api\Transformer\Data;
4
5
use League\Fractal\TransformerAbstract;
6
7
class CharacterTransformer 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
        $obj = [
19
            'id'          => (string) $data->character_id, // Bigint
20
            'name'        => (string) $data->name->first,
21
            'faction'     => (int) $data->faction_id,
22
            'br'          => (int) $data->battle_rank->value,
23
            'outfit'      => null,
24
            'server'      => (int) $data->world_id,
25
            'environment' => (string) $data->environment,
26
            'entered'     => (int) date('U')
27
        ];
28
29
        if (isset($data->outfit)) {
30
            $obj['outfit'] = $data->outfit->outfit_id;
31
        }
32
33
        return $obj;
34
    }
35
}
36