- Exception now called if a scalar value is supposed to be returned

This commit is contained in:
Dave M. 2023-05-31 18:30:55 +00:00
parent bc6344ad17
commit f92baa03c8
3 changed files with 5 additions and 6 deletions

View File

@ -6,7 +6,7 @@
"authors": [
{
"name": "Dave Mc Nicoll",
"email": "mcndave@gmail.com"
"email": "info@mcnd.ca"
}
],
"require": {},

View File

@ -50,10 +50,6 @@ class I18n implements MissingKeyInterface
$string = $this->missingKey ? $this->missingKey->get($key) : null;
}
#if (is_array($string)) {
# $string = json_encode($string);
#}
return $string && $variables ? $this->placeVariables($string, $variables) : $string;
}

View File

@ -59,7 +59,7 @@ class Iterate
if ( ! is_iterable($recurse) ) {
if ( is_object($recurse) ) {
if ( count($pathArr) > 1 ) {
throw new \Exception("An error occured trying to fetch a value from an object using path $path");
throw new \Exception("An error occured trying to fetch a value from an object using path '$path'");
}
else {
# @TODO An object caller would be a WAY better idea then this line of code
@ -67,6 +67,9 @@ class Iterate
return $recurse->{$pathArr[0]} ?? "";
}
}
elseif (is_scalar($recurse)) {
throw new \Exception("An error occured trying to fetch a value from a scalar value using path '$path'");
}
}
return static::arrayGet($recurse, implode($delimiter, $pathArr), $delimiter);