Conditions | 7 |
Paths | 8 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 7.6383 |
Changes | 0 |
1 | <?php |
||
30 | 8 | public function transform($value) |
|
31 | { |
||
32 | 8 | if (is_null($value)) { |
|
33 | 2 | return $value; |
|
34 | } |
||
35 | |||
36 | 6 | if (is_scalar($value)) { |
|
37 | 4 | return $this->getMappedValue($value); |
|
38 | } |
||
39 | |||
40 | 2 | if (is_array($value)) { |
|
41 | 2 | $newValue = []; |
|
42 | |||
43 | 2 | foreach ($value as $val) { |
|
44 | 2 | if (!is_array($val)) { |
|
45 | 2 | $val = [$val]; |
|
46 | } |
||
47 | 2 | foreach ($val as $val2) { |
|
48 | 2 | $newValue[] = $this->getMappedValue($val2); |
|
49 | } |
||
50 | } |
||
51 | |||
52 | 2 | return array_filter($newValue); |
|
53 | } |
||
54 | |||
55 | throw new TransformationFailedException( |
||
56 | sprintf( |
||
57 | 'Expected a scalar value or an array of scalar values to transform, got %s instead', |
||
58 | json_encode($value) |
||
59 | ) |
||
60 | ); |
||
61 | } |
||
62 | |||
85 |