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