Skip to content

Commit

Permalink
Use json_decode exception
Browse files Browse the repository at this point in the history
Ahora es más rápido.

Lo curioso es que si lo usan el jsonEncode().

Fix: #373
  • Loading branch information
joanhey authored Dec 9, 2023
1 parent faf1a6a commit fcbbf17
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/Shared/Domain/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ public static function jsonEncode(array $values): string

public static function jsonDecode(string $json): array
{
$data = json_decode($json, true);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error());
}

return $data;
return json_decode($json, true, flags: JSON_THROW_ON_ERROR);
}

public static function toSnakeCase(string $text): string
Expand Down

0 comments on commit fcbbf17

Please sign in to comment.