Skip to content

Commit

Permalink
Assume that json_decode always exists
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias Berchtold <[email protected]>
  • Loading branch information
matbech committed Nov 28, 2024
1 parent e4abef2 commit b5cbbb6
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/Controller/AbstractRestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use function call_user_func;
use function count;
use function explode;
use function function_exists;
use function get_debug_type;
use function is_array;
use function is_callable;
Expand Down Expand Up @@ -601,22 +600,15 @@ protected function processBodyContent(mixed $request)
/**
* Decode a JSON string.
*
* Uses json_decode by default. If that is not available, raises an exception.
* Uses json_decode by default.
*
* Marked protected to allow usage from extending classes.
*
* @param string $string
* @return mixed
* @throws Exception\DomainException If no JSON decoding functionality is available.
*/
protected function jsonDecode($string)
{
if (function_exists('json_decode')) {
return json_decode($string, (bool) $this->jsonDecodeType);
}

throw new DomainException(
'Unable to parse JSON request, due to missing ext/json'
);
return json_decode($string, (bool) $this->jsonDecodeType);
}
}

0 comments on commit b5cbbb6

Please sign in to comment.