Throw exception when depth is 0.
This commit is contained in:
parent
59c1876818
commit
1e4c40883a
@ -305,11 +305,8 @@ class Utils
|
|||||||
*/
|
*/
|
||||||
public static function jsonToArray($json, $depth=1)
|
public static function jsonToArray($json, $depth=1)
|
||||||
{
|
{
|
||||||
if (!is_int($depth)) {
|
if (!is_int($depth) || $depth <= 0) {
|
||||||
throw new InvalidArgumentException('jsonToArray depth must be int.');
|
throw new InvalidArgumentException('jsonToArray depth must be int and depth must bigger than 0.');
|
||||||
}
|
|
||||||
if ($depth <= 0) {
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
if ($json instanceof stdClass) {
|
if ($json instanceof stdClass) {
|
||||||
$json = (array) $json;
|
$json = (array) $json;
|
||||||
|
Loading…
Reference in New Issue
Block a user