protected function createPropertyValue(array $arr_field_def, $mix_value)
    {
        $obj_property_value = new \stdClass();

        // Indexed?
        $bol_index = TRUE;
        if(isset($arr_field_def['index']) && FALSE === $arr_field_def['index']) {
            $bol_index = FALSE;
        }
        $obj_property_value->excludeFromIndexes = !$bol_index;

        switch ($arr_field_def['type']) {
            case Schema::PROPERTY_STRING:
                $obj_property_value->stringValue = (string)$mix_value;
                break;

            case Schema::PROPERTY_INTEGER:
                $obj_property_value->integerValue = $mix_value;
                break;

            case Schema::PROPERTY_DATETIME:
                if($mix_value instanceof \DateTimeInterface) {
                    $obj_dtm = $mix_value;
                } else {
                    $obj_dtm = new \DateTimeImmutable($mix_value);
                }
                // A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
                $obj_property_value->timestampValue = $obj_dtm->format(self::DATETIME_FORMAT);
                break;

            case Schema::PROPERTY_DOUBLE:
            case Schema::PROPERTY_FLOAT:
                $obj_property_value->doubleValue = floatval($mix_value);
                break;

            case Schema::PROPERTY_BOOLEAN:
                $obj_property_value->booleanValue = (bool)$mix_value;
                break;

            case Schema::PROPERTY_GEOPOINT:
                if($mix_value instanceof Geopoint) {
                    /** @var Geopoint $mix_value */
                    $obj_property_value->geoPointValue = (object)[
                        "latitude" => $mix_value->getLatitude(),
                        "longitude" => $mix_value->getLongitude()
                    ];
                } elseif (is_array($mix_value)) {
                    $obj_property_value->geoPointValue = (object)[
                        "latitude" => $mix_value[0],
                        "longitude" => $mix_value[1]
                    ];
                } else {
                    throw new \InvalidArgumentException('Geopoint property data not supported: ' . gettype($mix_value));
                }
                break;

            case Schema::PROPERTY_STRING_LIST:
                // Docs: "A Value instance that sets field arrayValue must not set fields meaning or excludeFromIndexes."
                unset($obj_property_value->excludeFromIndexes);
                // As we cannot set excludeFromIndexes on the property itself, set it on each value in the array
                $arr_values = [];
                foreach ((array)$mix_value as $str) {
                    $obj_value = (object)['stringValue' => $str];
                    $obj_value->excludeFromIndexes = !$bol_index;
                    $arr_values[] = $obj_value;
                }
                $obj_property_value->arrayValue = (object)['values' => $arr_values];
                break;

            default:
                throw new \RuntimeException('Unable to process field type: ' . $arr_field_def['type']);
        }
        return $obj_property_value;
    }
protected function createPropertyValue(array $arr_field_def, $mix_value)
    {
        $obj_property_value = new \stdClass();

        // Indexed?
        $bol_index = TRUE;
        if(isset($arr_field_def['index']) && FALSE === $arr_field_def['index']) {
            $bol_index = FALSE;
        }
        $obj_property_value->excludeFromIndexes = !$bol_index;

        switch ($arr_field_def['type']) {
            case Schema::PROPERTY_STRING:
                $obj_property_value->stringValue = (string)$mix_value;
                break;

            case Schema::PROPERTY_INTEGER:
                $obj_property_value->integerValue = $mix_value;
                break;

            case Schema::PROPERTY_DATETIME:
                if($mix_value instanceof \DateTimeInterface) {
                    $obj_dtm = $mix_value;
                } else {
                    $obj_dtm = new \DateTimeImmutable($mix_value);
                }
                // A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
                $obj_property_value->timestampValue = $obj_dtm->format(self::DATETIME_FORMAT);
                break;

            case Schema::PROPERTY_DOUBLE:
            case Schema::PROPERTY_FLOAT:
                $obj_property_value->doubleValue = floatval($mix_value);
                break;

            case Schema::PROPERTY_BOOLEAN:
                $obj_property_value->booleanValue = (bool)$mix_value;
                break;

            case Schema::PROPERTY_GEOPOINT:
                if($mix_value instanceof Geopoint) {
                    /** @var Geopoint $mix_value */
                    $obj_property_value->geoPointValue = (object)[
                        "latitude" => $mix_value->getLatitude(),
                        "longitude" => $mix_value->getLongitude()
                    ];
                } elseif (is_array($mix_value)) {
                    $obj_property_value->geoPointValue = (object)[
                        "latitude" => $mix_value[0],
                        "longitude" => $mix_value[1]
                    ];
                } else {
                    throw new \InvalidArgumentException('Geopoint property data not supported: ' . gettype($mix_value));
                }
                break;

            case Schema::PROPERTY_STRING_LIST:
                // Docs: "A Value instance that sets field arrayValue must not set fields meaning or excludeFromIndexes."
                unset($obj_property_value->excludeFromIndexes);
                // As we cannot set excludeFromIndexes on the property itself, set it on each value in the array
                $arr_values = [];
                foreach ((array)$mix_value as $str) {
                    $obj_value = (object)['stringValue' => $str];
                    $obj_value->excludeFromIndexes = !$bol_index;
                    $arr_values[] = $obj_value;
                }
                $obj_property_value->arrayValue = (object)['values' => $arr_values];
                break;

            default:
                throw new \RuntimeException('Unable to process field type: ' . $arr_field_def['type']);
        }
        return $obj_property_value;
    }
protected function createPropertyValue ( array $ arr_field_def , $ mix_value ) { $ obj_property_value = new \ stdClass ( ) ; // Indexed? $ bol_index = TRUE ; if ( isset ( $ arr_field_def [ 'index' ] ) && FALSE === $ arr_field_def [ 'index' ] ) { $ bol_index = FALSE ; } $ obj_property_value -> excludeFromIndexes = ! $ bol_index ; switch ( $ arr_field_def [ 'type' ] ) { case Schema :: PROPERTY_STRING : $ obj_property_value -> stringValue = ( string ) $ mix_value ; break ; case Schema :: PROPERTY_INTEGER : $ obj_property_value -> integerValue = $ mix_value ; break ; case Schema :: PROPERTY_DATETIME : if ( $ mix_value instanceof \ DateTimeInterface ) { $ obj_dtm = $ mix_value ; } else { $ obj_dtm = new \ DateTimeImmutable ( $ mix_value ) ; } // A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z". $ obj_property_value -> timestampValue = $ obj_dtm -> format ( self :: DATETIME_FORMAT ) ; break ; case Schema :: PROPERTY_DOUBLE : case Schema :: PROPERTY_FLOAT : $ obj_property_value -> doubleValue = floatval ( $ mix_value ) ; break ; case Schema :: PROPERTY_BOOLEAN : $ obj_property_value -> booleanValue = ( bool ) $ mix_value ; break ; case Schema :: PROPERTY_GEOPOINT : if ( $ mix_value instanceof Geopoint ) { /** @var Geopoint $mix_value */ $ obj_property_value -> geoPointValue = ( object ) [ "latitude" => $ mix_value -> getLatitude ( ) , "longitude" => $ mix_value -> getLongitude ( ) ] ; } elseif ( is_array ( $ mix_value ) ) { $ obj_property_value -> geoPointValue = ( object ) [ "latitude" => $ mix_value [ 0 ] , "longitude" => $ mix_value [ 1 ] ] ; } else { throw new \ InvalidArgumentException ( 'Geopoint property data not supported: ' . gettype ( $ mix_value ) ) ; } break ; case Schema :: PROPERTY_STRING_LIST : // Docs: "A Value instance that sets field arrayValue must not set fields meaning or excludeFromIndexes." unset ( $ obj_property_value -> excludeFromIndexes ) ; // As we cannot set excludeFromIndexes on the property itself, set it on each value in the array $ arr_values = [ ] ; foreach ( ( array ) $ mix_value as $ str ) { $ obj_value = ( object ) [ 'stringValue' => $ str ] ; $ obj_value -> excludeFromIndexes = ! $ bol_index ; $ arr_values [ ] = $ obj_value ; } $ obj_property_value -> arrayValue = ( object ) [ 'values' => $ arr_values ] ; break ; default : throw new \ RuntimeException ( 'Unable to process field type: ' . $ arr_field_def [ 'type' ] ) ; } return $ obj_property_value ; }
Create a property object

@todo Compare with parameter value method from REST Gateway

@param array $arr_field_def
@param $mix_value
@return mixed
Create a property object