protected function normalize($data)
    {
        if (null === $data || is_scalar($data)) {
            return $data;
        }

        if (is_array($data)) {
            foreach ($data as $key => $val) {
                $data[$key] = $this->normalize($val);
            }

            return $data;
        }

        throw new \RuntimeException('An unexpected value could not be normalized: '.var_export($data, true));
    }
protected function normalize($data)
    {
        if (null === $data || is_scalar($data)) {
            return $data;
        }

        if (is_array($data)) {
            foreach ($data as $key => $val) {
                $data[$key] = $this->normalize($val);
            }

            return $data;
        }

        throw new \RuntimeException('An unexpected value could not be normalized: '.var_export($data, true));
    }
protected function normalize ( $ data ) { if ( null === $ data || is_scalar ( $ data ) ) { return $ data ; } if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ val ) { $ data [ $ key ] = $ this -> normalize ( $ val ) ; } return $ data ; } throw new \ RuntimeException ( 'An unexpected value could not be normalized: ' . var_export ( $ data , true ) ) ; }
Normalize php data for mongo

This code chunk was inspired by the Symfony framework
and is subject to the MIT license. Please see the LICENCE
at https://github.com/symfony/symfony

(c) Fabien Potencier <fabien@symfony.com>
Author Nils Adermann <naderman@naderman.de>

@param mixed $data

@return mixed
Normalize php data for mongo