I would even reduce the indentation of the whole method code, by switching the condition:

```php
if (function_exists('json_last_error_msg')) {
    return json_last_error_msg();
}

switch (json_last_error()) {
    // ...
}
```