public static function convertObjectToArray($subject): array
    {
        if (!is_object($subject) && !is_array($subject)) {
            throw new \InvalidArgumentException('convertObjectToArray expects either array or object as input, ' . gettype($subject) . ' given.', 1287059709);
        }
        if (is_object($subject)) {
            $subject = (array)$subject;
        }
        foreach ($subject as $key => $value) {
            if (is_array($value) || is_object($value)) {
                $subject[$key] = self::convertObjectToArray($value);
            }
        }
        return $subject;
    }
public static function convertObjectToArray($subject): array
    {
        if (!is_object($subject) && !is_array($subject)) {
            throw new \InvalidArgumentException('convertObjectToArray expects either array or object as input, ' . gettype($subject) . ' given.', 1287059709);
        }
        if (is_object($subject)) {
            $subject = (array)$subject;
        }
        foreach ($subject as $key => $value) {
            if (is_array($value) || is_object($value)) {
                $subject[$key] = self::convertObjectToArray($value);
            }
        }
        return $subject;
    }
public static function convertObjectToArray ( $ subject ) : array { if ( ! is_object ( $ subject ) && ! is_array ( $ subject ) ) { throw new \ InvalidArgumentException ( 'convertObjectToArray expects either array or object as input, ' . gettype ( $ subject ) . ' given.' , 1287059709 ) ; } if ( is_object ( $ subject ) ) { $ subject = ( array ) $ subject ; } foreach ( $ subject as $ key => $ value ) { if ( is_array ( $ value ) || is_object ( $ value ) ) { $ subject [ $ key ] = self :: convertObjectToArray ( $ value ) ; } } return $ subject ; }
Recursively convert an object hierarchy into an associative array.

@param mixed $subject An object or array of objects
@return array The subject represented as an array
@throws \InvalidArgumentException
Recursively convert an object hierarchy into an associative array .