public function serialize($object)
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('Argument must be an object');
        }

        $reflectedObject = new \ReflectionObject($object);
        $reflectedProperties = $reflectedObject->getProperties();

        $array = array();

        foreach ($reflectedProperties as $property) {
            $value = $this->getValue($object, $property);

            if (null !== $value) {
                if (!is_scalar($value)) {
                    $value = $this->normalize($value);
                }

                $array[$this->formatter->toMongoKey($property->getName())] = $value;
            }
        }

        return $array;
    }
public function serialize($object)
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('Argument must be an object');
        }

        $reflectedObject = new \ReflectionObject($object);
        $reflectedProperties = $reflectedObject->getProperties();

        $array = array();

        foreach ($reflectedProperties as $property) {
            $value = $this->getValue($object, $property);

            if (null !== $value) {
                if (!is_scalar($value)) {
                    $value = $this->normalize($value);
                }

                $array[$this->formatter->toMongoKey($property->getName())] = $value;
            }
        }

        return $array;
    }
public function serialize ( $ object ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( 'Argument must be an object' ) ; } $ reflectedObject = new \ ReflectionObject ( $ object ) ; $ reflectedProperties = $ reflectedObject -> getProperties ( ) ; $ array = array ( ) ; foreach ( $ reflectedProperties as $ property ) { $ value = $ this -> getValue ( $ object , $ property ) ; if ( null !== $ value ) { if ( ! is_scalar ( $ value ) ) { $ value = $ this -> normalize ( $ value ) ; } $ array [ $ this -> formatter -> toMongoKey ( $ property -> getName ( ) ) ] = $ value ; } } return $ array ; }
Convert an object to a mongoable array

@param mixed $object

@return array
Convert an object to a mongoable array