Skip to content

Commit

Permalink
Introduce convertObjectToArray method in AbstractFilter class
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Cassani committed Aug 24, 2017
1 parent 9abff94 commit ef15e97
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Filters/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,29 @@ protected static function getArrayElementValueFromKey($key, $arrayElement)
{
return self::getValueFromKeysArray(
explode(self::ARRAY_SEPARATOR, $key),
(array) $arrayElement
(is_object($arrayElement)) ? self::convertObjectToArray($arrayElement) : $arrayElement
);
}

/**
* @param $arrayElement
* @return array
*/
private static function convertObjectToArray($arrayElement)
{
$convertedArray = [];

foreach ((array)$arrayElement as $key => $element){
$key = explode("\\", $key);
$key = end($key);
$key = explode("\000", $key);

$convertedArray[end($key)] = $element;
}

return $convertedArray;
}

/**
* @param $keysArray
* @param $arrayElement
Expand Down

0 comments on commit ef15e97

Please sign in to comment.