Conditions | 4 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
11 | 23 | public function cast($value) |
|
12 | { |
||
13 | 23 | if (is_string($value)) { |
|
14 | 13 | $result = json_decode($value, true); |
|
15 | 13 | if (json_last_error() === \JSON_ERROR_NONE) { |
|
16 | 10 | return (array) $result; |
|
17 | } |
||
18 | 3 | $result = json_decode("[{$value}]", true); |
|
19 | 3 | if (json_last_error() === \JSON_ERROR_NONE) { |
|
20 | 3 | return (array) $result; |
|
21 | } |
||
22 | } |
||
23 | 10 | return (array) $value; |
|
24 | } |
||
25 | } |
||
26 |