@@ -193,21 +193,21 @@ protected function isMultiArray($arr)
193
193
*
194
194
* @param string $value
195
195
* @param bool $isReturnMap
196
- *
196
+ *
197
197
* @return bool|array
198
198
*/
199
199
public function isJson ($ value , $ isReturnMap = false )
200
200
{
201
201
if (is_array ($ value ) || is_object ($ value )) {
202
202
return false ;
203
203
}
204
-
204
+
205
205
$ data = json_decode ($ value , true );
206
206
207
207
if (json_last_error () !== JSON_ERROR_NONE ) {
208
208
return false ;
209
209
}
210
-
210
+
211
211
return $ isReturnMap ? $ data : true ;
212
212
}
213
213
@@ -300,11 +300,11 @@ protected function getDataFromFile($file, $type = 'application/json')
300
300
$ context = stream_context_create ($ opts );
301
301
$ data = file_get_contents ($ file , 0 , $ context );
302
302
$ json = $ this ->isJson ($ data , true );
303
-
303
+
304
304
if (!$ json ) {
305
305
throw new InvalidJsonException ();
306
306
}
307
-
307
+
308
308
return $ json ;
309
309
}
310
310
@@ -331,6 +331,8 @@ protected function getFromNested($map, $node)
331
331
$ path = explode ('. ' , $ node );
332
332
333
333
foreach ($ path as $ val ) {
334
+ if (!is_array ($ map )) return $ map ;
335
+
334
336
if (!array_key_exists ($ val , $ map )) {
335
337
$ terminate = true ;
336
338
break ;
@@ -379,10 +381,10 @@ protected function processConditions()
379
381
if (!method_exists (Condition::class, $ function )) {
380
382
throw new ConditionNotAllowedException ("Exception: $ function condition not allowed " );
381
383
}
382
-
384
+
383
385
$ function = [Condition::class, $ function ];
384
386
}
385
-
387
+
386
388
$ value = $ this ->getFromNested ($ val , $ rule ['key ' ]);
387
389
$ return = $ value instanceof ValueNotFound ? false : call_user_func_array ($ function , [$ value , $ rule ['value ' ]]);
388
390
$ tmp &= $ return ;
0 commit comments