diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index 7b108491ae31..5688dced0fea 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -231,15 +231,19 @@ function cache() return app('cache')->get($arguments[0], isset($arguments[1]) ? $arguments[1] : null); } - if (is_array($arguments[0])) { - if (! isset($arguments[1])) { - throw new Exception( - 'You must set an expiration time when putting to the cache.' - ); - } + if (! is_array($arguments[0])) { + throw new Exception( + 'The argument passed to the cache must be a string or an array.' + ); + } - return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1]); + if (! isset($arguments[1])) { + throw new Exception( + 'You must set an expiration time when putting to the cache.' + ); } + + return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1]); } }