Completed
Pull Request — master (#8)
by Michael
05:39
created

NoneTransformer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transformOutput() 0 7 2
A transformInput() 0 7 2
1
<?php
2
3
namespace Napp\Core\Api\Transformers;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use Illuminate\Support\Arr;
7
8
class NoneTransformer implements TransformerInterface
9
{
10
    /**
11
     * @param array|Arrayable $data
12
     * @return array
13
     */
14
    public function transformInput($data): array
15
    {
16
        if ($data instanceof Arrayable) {
17
            return $data->toArray();
18
        }
19
20
        return Arr::wrap($data);
21
    }
22
23
    /**
24
     * @param array|Arrayable $data
25
     * @return array
26
     */
27
    public function transformOutput($data): array
28
    {
29
        if ($data instanceof Arrayable) {
30
            return $data->toArray();
31
        }
32
33
        return Arr::wrap($data);
34
    }
35
}
36