updated composer
This commit is contained in:
+8
-1
@@ -13,6 +13,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Jose\Component\Core\Util;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use function is_string;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
@@ -26,7 +28,12 @@ final class JsonConverter
|
||||
public static function encode($payload): string
|
||||
{
|
||||
try {
|
||||
return json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
$data = json_encode($payload, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
if (!is_string($data)) {
|
||||
throw new InvalidArgumentException('Unable to encode the data');
|
||||
}
|
||||
|
||||
return $data;
|
||||
} catch (Throwable $throwable) {
|
||||
throw new RuntimeException('Invalid content.', $throwable->getCode(), $throwable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user