Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 5 | public function reverseTransform($string) |
|
40 | { |
||
41 | //JSON requests will already be strings |
||
42 | 5 | if (is_array($string)) { |
|
43 | 2 | return $string; |
|
44 | } |
||
45 | //strip any whitespace |
||
46 | 3 | $string = preg_replace('/^\s+|\s+$/u', '', $string); |
|
47 | 3 | $string = preg_replace('/\s+,\s*/u', ',', $string); |
|
48 | 3 | if (empty($string)) { |
|
49 | 1 | return []; |
|
50 | } |
||
51 | |||
52 | 2 | return explode(',', $string); |
|
53 | } |
||
54 | } |
||
55 |