From ef15e97e776724327200561ab99f5f1d69d500f5 Mon Sep 17 00:00:00 2001 From: Mauro Cassani Date: Thu, 24 Aug 2017 17:15:24 +0200 Subject: [PATCH] Introduce convertObjectToArray method in AbstractFilter class --- src/Filters/AbstractFilter.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Filters/AbstractFilter.php b/src/Filters/AbstractFilter.php index 5744c25..092dc19 100644 --- a/src/Filters/AbstractFilter.php +++ b/src/Filters/AbstractFilter.php @@ -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