Skip to content

Commit 8b38cea

Browse files
author
Mehedi Hasan Nahid
committed
fixed: issue-49
1 parent 99533dd commit 8b38cea

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/JsonQueriable.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,21 @@ protected function isMultiArray($arr)
193193
*
194194
* @param string $value
195195
* @param bool $isReturnMap
196-
*
196+
*
197197
* @return bool|array
198198
*/
199199
public function isJson($value, $isReturnMap = false)
200200
{
201201
if (is_array($value) || is_object($value)) {
202202
return false;
203203
}
204-
204+
205205
$data = json_decode($value, true);
206206

207207
if (json_last_error() !== JSON_ERROR_NONE) {
208208
return false;
209209
}
210-
210+
211211
return $isReturnMap ? $data : true;
212212
}
213213

@@ -300,11 +300,11 @@ protected function getDataFromFile($file, $type = 'application/json')
300300
$context = stream_context_create($opts);
301301
$data = file_get_contents($file, 0, $context);
302302
$json = $this->isJson($data, true);
303-
303+
304304
if (!$json) {
305305
throw new InvalidJsonException();
306306
}
307-
307+
308308
return $json;
309309
}
310310

@@ -331,6 +331,8 @@ protected function getFromNested($map, $node)
331331
$path = explode('.', $node);
332332

333333
foreach ($path as $val) {
334+
if (!is_array($map)) return $map;
335+
334336
if (!array_key_exists($val, $map)) {
335337
$terminate = true;
336338
break;
@@ -379,10 +381,10 @@ protected function processConditions()
379381
if (!method_exists(Condition::class, $function)) {
380382
throw new ConditionNotAllowedException("Exception: $function condition not allowed");
381383
}
382-
384+
383385
$function = [Condition::class, $function];
384386
}
385-
387+
386388
$value = $this->getFromNested($val, $rule['key']);
387389
$return = $value instanceof ValueNotFound ? false : call_user_func_array($function, [$value, $rule['value']]);
388390
$tmp &= $return;

0 commit comments

Comments
 (0)