Skip to content

Commit

Permalink
fix object data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yus-ham committed Jan 27, 2024
1 parent 14f0839 commit c60cd4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public static function parametrizedMerge(array $arrays, ?int $depth): array
* getting value from an object.
*
* @psalm-param ArrayKey|Closure $key
*
*
* @throws InvalidArgumentException if `$array` is an object.
* @return mixed The value of the element if found or the return value of callable is truthy, default value otherwise.
*/
public static function getValue(
Expand All @@ -193,6 +194,9 @@ public static function getValue(
mixed $default = null
): mixed {
if ($key instanceof Closure) {
if (is_object($array)) {
throw new InvalidArgumentException('Matcher cannot be applied to an object');
}
return self::getValueByMatcher($array, $key, $default);
}

Expand Down

0 comments on commit c60cd4b

Please sign in to comment.