Datastore/src/EntityMapper.php
public function objectProperty($value)
    {
        switch (true) {
            case $value instanceof Int64:
                return [
                    'integerValue' => $value->get()
                ];

                break;
            case $value instanceof Blob:
                return [
                    'blobValue' => ($this->encode)
                        ? base64_encode((string) $value)
                        : (string) $value
                ];

                break;

            case $value instanceof \DateTimeInterface:
                return [
                    'timestampValue' => $value->format(self::DATE_FORMAT)
                ];

                break;

            case $value instanceof EntityInterface:
                return [
                    'entityValue' => $this->objectToRequest($value)
                ];

                break;

            case $value instanceof GeoPoint:
                return [
                    'geoPointValue' => $value->point()
                ];

                break;

            case $value instanceof Key:
                return [
                    'keyValue' => $value->keyObject()
                ];

                break;

            case $value instanceof \stdClass:
                return $this->convertArrayToEntityValue((array) $value);

            default:
                throw new \InvalidArgumentException(
                    sprintf('Value of type `%s` could not be serialized', get_class($value))
                );

                break;
        }
    }
public function objectProperty($value)
    {
        switch (true) {
            case $value instanceof Int64:
                return [
                    'integerValue' => $value->get()
                ];

                break;
            case $value instanceof Blob:
                return [
                    'blobValue' => ($this->encode)
                        ? base64_encode((string) $value)
                        : (string) $value
                ];

                break;

            case $value instanceof \DateTimeInterface:
                return [
                    'timestampValue' => $value->format(self::DATE_FORMAT)
                ];

                break;

            case $value instanceof EntityInterface:
                return [
                    'entityValue' => $this->objectToRequest($value)
                ];

                break;

            case $value instanceof GeoPoint:
                return [
                    'geoPointValue' => $value->point()
                ];

                break;

            case $value instanceof Key:
                return [
                    'keyValue' => $value->keyObject()
                ];

                break;

            case $value instanceof \stdClass:
                return $this->convertArrayToEntityValue((array) $value);

            default:
                throw new \InvalidArgumentException(
                    sprintf('Value of type `%s` could not be serialized', get_class($value))
                );

                break;
        }
    }
public function objectProperty ( $ value ) { switch ( true ) { case $ value instanceof Int64 : return [ 'integerValue' => $ value -> get ( ) ] ; break ; case $ value instanceof Blob : return [ 'blobValue' => ( $ this -> encode ) ? base64_encode ( ( string ) $ value ) : ( string ) $ value ] ; break ; case $ value instanceof \ DateTimeInterface : return [ 'timestampValue' => $ value -> format ( self :: DATE_FORMAT ) ] ; break ; case $ value instanceof EntityInterface : return [ 'entityValue' => $ this -> objectToRequest ( $ value ) ] ; break ; case $ value instanceof GeoPoint : return [ 'geoPointValue' => $ value -> point ( ) ] ; break ; case $ value instanceof Key : return [ 'keyValue' => $ value -> keyObject ( ) ] ; break ; case $ value instanceof \ stdClass : return $ this -> convertArrayToEntityValue ( ( array ) $ value ) ; default : throw new \ InvalidArgumentException ( sprintf ( 'Value of type `%s` could not be serialized' , get_class ( $ value ) ) ) ; break ; } }
Convert different object types to API values

@todo add middleware

@param mixed $value The value object
@return array
Convert different object types to API values