Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
30 | public static function isJsonString($string) |
||
31 | { |
||
32 | $string = trim($string); |
||
33 | |||
34 | if (substr($string, 0, 1) === '{' && substr($string, -1, 1) === '}') { |
||
35 | try { |
||
36 | json_decode($string); |
||
37 | return json_last_error() === JSON_ERROR_NONE; |
||
38 | } catch (\Exception $e) { |
||
|
|||
39 | |||
40 | } |
||
41 | } |
||
42 | |||
43 | return false; |
||
44 | } |
||
45 | |||
60 |