src/Serializer.php
protected function serializeAttribute($value, AttributeMetadata $attrMeta)
    {
        if ('date' === $attrMeta->dataType && $value instanceof \DateTime) {
            $milliseconds = sprintf('%03d', round($value->format('u') / 1000, 0));
            return gmdate(sprintf('Y-m-d\TH:i:s.%s\Z', $milliseconds), $value->getTimestamp());
        }
        if ('array' === $attrMeta->dataType && empty($value)) {
            return [];
        }
        if ('object' === $attrMeta->dataType) {
            return (array) $value;
        }
        return $value;
    }
protected function serializeAttribute($value, AttributeMetadata $attrMeta)
    {
        if ('date' === $attrMeta->dataType && $value instanceof \DateTime) {
            $milliseconds = sprintf('%03d', round($value->format('u') / 1000, 0));
            return gmdate(sprintf('Y-m-d\TH:i:s.%s\Z', $milliseconds), $value->getTimestamp());
        }
        if ('array' === $attrMeta->dataType && empty($value)) {
            return [];
        }
        if ('object' === $attrMeta->dataType) {
            return (array) $value;
        }
        return $value;
    }
protected function serializeAttribute ( $ value , AttributeMetadata $ attrMeta ) { if ( 'date' === $ attrMeta -> dataType && $ value instanceof \ DateTime ) { $ milliseconds = sprintf ( '%03d' , round ( $ value -> format ( 'u' ) / 1000 , 0 ) ) ; return gmdate ( sprintf ( 'Y-m-d\TH:i:s.%s\Z' , $ milliseconds ) , $ value -> getTimestamp ( ) ) ; } if ( 'array' === $ attrMeta -> dataType && empty ( $ value ) ) { return [ ] ; } if ( 'object' === $ attrMeta -> dataType ) { return ( array ) $ value ; } return $ value ; }
Serializes an attribute value.

@param   mixed               $value
@param   AttributeMetadata   $attrMeta
@return  mixed
Serializes an attribute value .