src/Formatter.php
public function getAttributeDbValue(AttributeMetadata $attrMeta, $value)
    {
        // Handle data type conversion, if needed.
        if ('date' === $attrMeta->dataType && $value instanceof \DateTime) {
            return new \MongoDate($value->getTimestamp(), $value->format('u'));
        }
        if ('array' === $attrMeta->dataType && empty($value)) {
            return;
        }
        if ('object' === $attrMeta->dataType) {
            $array = (array) $value;
            return empty($array) ? null : $value;
        }
        return $value;
    }
public function getAttributeDbValue(AttributeMetadata $attrMeta, $value)
    {
        // Handle data type conversion, if needed.
        if ('date' === $attrMeta->dataType && $value instanceof \DateTime) {
            return new \MongoDate($value->getTimestamp(), $value->format('u'));
        }
        if ('array' === $attrMeta->dataType && empty($value)) {
            return;
        }
        if ('object' === $attrMeta->dataType) {
            $array = (array) $value;
            return empty($array) ? null : $value;
        }
        return $value;
    }
public function getAttributeDbValue ( AttributeMetadata $ attrMeta , $ value ) { // Handle data type conversion, if needed. if ( 'date' === $ attrMeta -> dataType && $ value instanceof \ DateTime ) { return new \ MongoDate ( $ value -> getTimestamp ( ) , $ value -> format ( 'u' ) ) ; } if ( 'array' === $ attrMeta -> dataType && empty ( $ value ) ) { return ; } if ( 'object' === $ attrMeta -> dataType ) { $ array = ( array ) $ value ; return empty ( $ array ) ? null : $ value ; } return $ value ; }
Prepares and formats an attribute value for proper insertion into the database.

@param   AttributeMetadata   $attrMeta
@param   mixed               $value
@return  mixed
Prepares and formats an attribute value for proper insertion into the database .