Passed
Push — master ( e122d6...753728 )
by Alexander
02:47
created

ArrayTransformer::transform()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Flugg\Responder\Transformers;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
7
/**
8
 * A transformer class for transforming data into an array without manipulations.
9
 *
10
 * @package flugger/laravel-responder
11
 * @author  Alexander Tømmerås <[email protected]>
12
 * @license The MIT License
13
 */
14
class ArrayTransformer extends Transformer
15
{
16
    /**
17
     * Transform the data.
18
     *
19
     * @param  mixed $data
20
     * @return array
21
     */
22 20
    public function transform($data)
23
    {
24 20
        return $data instanceof Arrayable ? $data->toArray() : $data;
25
    }
26
}