Datastore/src/EntityMapper.php
public function valueObject($value, $exclude = false, $meaning = null)
    {
        switch (gettype($value)) {
            case 'boolean':
                $propertyValue = [
                    'booleanValue' => $value
                ];

                break;

            case 'integer':
                $propertyValue = [
                    'integerValue' => $value
                ];

                break;

            case 'double':
                $propertyValue = [
                    'doubleValue' => $value
                ];

                break;

            case 'string':
                $propertyValue = [
                    'stringValue' => $value
                ];

                break;

            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    $propertyValue = $this->convertArrayToEntityValue($value);
                } else {
                    $propertyValue = $this->convertArrayToArrayValue($value);
                }

                break;

            case 'object':
                $propertyValue = $this->objectProperty($value);
                break;

            case 'resource':
                $content = stream_get_contents($value);

                $propertyValue = [
                    'blobValue' => ($this->encode)
                        ? base64_encode($content)
                        : $content
                ];
                break;

            case 'NULL':
                $propertyValue = [
                    'nullValue' => null
                ];
                break;

            //@codeCoverageIgnoreStart
            case 'unknown type':
                throw new \InvalidArgumentException(sprintf(
                    'Unknown type for `%s',
                    $content
                ));
                break;

            default:
                throw new \InvalidArgumentException(sprintf(
                    'Invalid type for `%s',
                    $content
                ));
                break;
            //@codeCoverageIgnoreEnd
        }

        if ($exclude) {
            $propertyValue['excludeFromIndexes'] = true;
        }

        if ($meaning) {
            $propertyValue['meaning'] = $meaning;
        }

        return $propertyValue;
    }
public function valueObject($value, $exclude = false, $meaning = null)
    {
        switch (gettype($value)) {
            case 'boolean':
                $propertyValue = [
                    'booleanValue' => $value
                ];

                break;

            case 'integer':
                $propertyValue = [
                    'integerValue' => $value
                ];

                break;

            case 'double':
                $propertyValue = [
                    'doubleValue' => $value
                ];

                break;

            case 'string':
                $propertyValue = [
                    'stringValue' => $value
                ];

                break;

            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    $propertyValue = $this->convertArrayToEntityValue($value);
                } else {
                    $propertyValue = $this->convertArrayToArrayValue($value);
                }

                break;

            case 'object':
                $propertyValue = $this->objectProperty($value);
                break;

            case 'resource':
                $content = stream_get_contents($value);

                $propertyValue = [
                    'blobValue' => ($this->encode)
                        ? base64_encode($content)
                        : $content
                ];
                break;

            case 'NULL':
                $propertyValue = [
                    'nullValue' => null
                ];
                break;

            //@codeCoverageIgnoreStart
            case 'unknown type':
                throw new \InvalidArgumentException(sprintf(
                    'Unknown type for `%s',
                    $content
                ));
                break;

            default:
                throw new \InvalidArgumentException(sprintf(
                    'Invalid type for `%s',
                    $content
                ));
                break;
            //@codeCoverageIgnoreEnd
        }

        if ($exclude) {
            $propertyValue['excludeFromIndexes'] = true;
        }

        if ($meaning) {
            $propertyValue['meaning'] = $meaning;
        }

        return $propertyValue;
    }
public function valueObject ( $ value , $ exclude = false , $ meaning = null ) { switch ( gettype ( $ value ) ) { case 'boolean' : $ propertyValue = [ 'booleanValue' => $ value ] ; break ; case 'integer' : $ propertyValue = [ 'integerValue' => $ value ] ; break ; case 'double' : $ propertyValue = [ 'doubleValue' => $ value ] ; break ; case 'string' : $ propertyValue = [ 'stringValue' => $ value ] ; break ; case 'array' : if ( ! empty ( $ value ) && $ this -> isAssoc ( $ value ) ) { $ propertyValue = $ this -> convertArrayToEntityValue ( $ value ) ; } else { $ propertyValue = $ this -> convertArrayToArrayValue ( $ value ) ; } break ; case 'object' : $ propertyValue = $ this -> objectProperty ( $ value ) ; break ; case 'resource' : $ content = stream_get_contents ( $ value ) ; $ propertyValue = [ 'blobValue' => ( $ this -> encode ) ? base64_encode ( $ content ) : $ content ] ; break ; case 'NULL' : $ propertyValue = [ 'nullValue' => null ] ; break ; //@codeCoverageIgnoreStart case 'unknown type' : throw new \ InvalidArgumentException ( sprintf ( 'Unknown type for `%s' , $ content ) ) ; break ; default : throw new \ InvalidArgumentException ( sprintf ( 'Invalid type for `%s' , $ content ) ) ; break ; //@codeCoverageIgnoreEnd } if ( $ exclude ) { $ propertyValue [ 'excludeFromIndexes' ] = true ; } if ( $ meaning ) { $ propertyValue [ 'meaning' ] = $ meaning ; } return $ propertyValue ; }
Format values for the API

@param mixed $value
@param bool $exclude [optional] If true, value will be excluded from datastore indexes.
@param int $meaning [optional] The Meaning value. Maintained only for backwards compatibility.
@return array
Format values for the API