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

ArrayTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 13
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 4 2
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
}