| Conditions | 5 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.583 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 16 | public function convert(string $dataString) |
|
| 35 | { |
||
| 36 | 16 | $unserialized = unserialize($dataString, ['allowed_classes' => false]); |
|
| 37 | |||
| 38 | 16 | if (is_object($unserialized)) { |
|
| 39 | 1 | throw new \Exception('Objects are not allowed' . var_export($unserialized, true), 1593758307); |
|
| 40 | } |
||
| 41 | |||
| 42 | 15 | if ($unserialized && ! is_object($unserialized)) { |
|
| 43 | 1 | return $unserialized; |
|
| 44 | } |
||
| 45 | |||
| 46 | 14 | $decoded = json_decode($dataString, true); |
|
| 47 | 14 | if ($decoded) { |
|
| 48 | 11 | return $decoded; |
|
| 49 | } |
||
| 50 | |||
| 51 | 3 | return false; |
|
| 52 | } |
||
| 54 |