Core/src/GrpcTrait.php
private function formatValueForApi($value)
    {
        $type = gettype($value);

        switch ($type) {
            case 'string':
                return ['string_value' => $value];
            case 'double':
            case 'integer':
                return ['number_value' => $value];
            case 'boolean':
                return ['bool_value' => $value];
            case 'NULL':
                return ['null_value' => NullValue::NULL_VALUE];
            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    return ['struct_value' => $this->formatStructForApi($value)];
                }

                return ['list_value' => $this->formatListForApi($value)];
        }
    }
private function formatValueForApi($value)
    {
        $type = gettype($value);

        switch ($type) {
            case 'string':
                return ['string_value' => $value];
            case 'double':
            case 'integer':
                return ['number_value' => $value];
            case 'boolean':
                return ['bool_value' => $value];
            case 'NULL':
                return ['null_value' => NullValue::NULL_VALUE];
            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    return ['struct_value' => $this->formatStructForApi($value)];
                }

                return ['list_value' => $this->formatListForApi($value)];
        }
    }
private function formatValueForApi ( $ value ) { $ type = gettype ( $ value ) ; switch ( $ type ) { case 'string' : return [ 'string_value' => $ value ] ; case 'double' : case 'integer' : return [ 'number_value' => $ value ] ; case 'boolean' : return [ 'bool_value' => $ value ] ; case 'NULL' : return [ 'null_value' => NullValue :: NULL_VALUE ] ; case 'array' : if ( ! empty ( $ value ) && $ this -> isAssoc ( $ value ) ) { return [ 'struct_value' => $ this -> formatStructForApi ( $ value ) ] ; } return [ 'list_value' => $ this -> formatListForApi ( $ value ) ] ; } }
Format a value for the API.

@param array $value
@return array
Format a value for the API .