From 1e4c40883a184864b2330d4a70fd2ff98a17f340 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Tue, 26 Dec 2017 12:06:58 +0800 Subject: [PATCH] Throw exception when depth is 0. --- src/Utils.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Utils.php b/src/Utils.php index ebe959f..3641f59 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -305,11 +305,8 @@ class Utils */ public static function jsonToArray($json, $depth=1) { - if (!is_int($depth)) { - throw new InvalidArgumentException('jsonToArray depth must be int.'); - } - if ($depth <= 0) { - return []; + if (!is_int($depth) || $depth <= 0) { + throw new InvalidArgumentException('jsonToArray depth must be int and depth must bigger than 0.'); } if ($json instanceof stdClass) { $json = (array) $json;