class ObjectSerializer

ObjectSerializer Class Doc Comment

Methods

static 
setDateTimeFormat(string $format)

Change the date format

static scalar|object|array|null
sanitizeForSerialization(mixed $data, string $type = null, string $format = null)

Serialize data

static string
sanitizeFilename(string $filename)

Sanitize filename by removing path.

static string
sanitizeTimestamp(string $timestamp)

Shorter timestamp microseconds to 6 digits length.

static string
toPathValue(string $value)

Take value and turn it into a string suitable for inclusion in the path, by url-encoding.

static array
toQueryValue(mixed $value, string $paramName, string $openApiType = 'string', string $style = 'form', bool $explode = true, bool $required = true)

Take query parameter properties and turn it into an array suitable for native http_build_query or GuzzleHttp\Psr7\Query::build.

static int|string
convertBoolToQueryStringFormat(bool $value)

Convert boolean value to format for query string.

static string
toHeaderValue(string $value)

Take value and turn it into a string suitable for inclusion in the header. If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601

static string
toFormValue(string|SplFileObject $value)

Take value and turn it into a string suitable for inclusion in the http body (form parameter). If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601

static string
toString(string|bool|DateTime $value)

Take value and turn it into a string suitable for inclusion in the parameter. If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601 If it's a boolean, convert it to "true" or "false".

static string
serializeCollection(array $collection, string $style, bool $allowCollectionFormatMulti = false)

Serialize an array to a string.

static object|array|null
deserialize(mixed $data, string $class, string[] $httpHeaders = null)

Deserialize a JSON string into an object

static string
buildQuery(array|object $data, string $numeric_prefix = '', string|null $arg_separator = null, int $encoding_type = \PHP_QUERY_RFC3986)

Native http_build_query wrapper.

Details

at line 52
static setDateTimeFormat(string $format)

Change the date format

Parameters

string $format

the new date format to use

at line 66
static scalar|object|array|null sanitizeForSerialization(mixed $data, string $type = null, string $format = null)

Serialize data

Parameters

mixed $data

the data to serialize

string $type

the OpenAPIToolsType of the data

string $format

the format of the OpenAPITools type of the data

Return Value

scalar|object|array|null

serialized form of $data

at line 124
static string sanitizeFilename(string $filename)

Sanitize filename by removing path.

e.g. ../../sun.gif becomes sun.gif

Parameters

string $filename

filename to be sanitized

Return Value

string

the sanitized filename

at line 140
static string sanitizeTimestamp(string $timestamp)

Shorter timestamp microseconds to 6 digits length.

Parameters

string $timestamp

Original timestamp

Return Value

string

the shorten timestamp

at line 155
static string toPathValue(string $value)

Take value and turn it into a string suitable for inclusion in the path, by url-encoding.

Parameters

string $value

a string which will be part of the path

Return Value

string

the serialized object

at line 173
static array toQueryValue(mixed $value, string $paramName, string $openApiType = 'string', string $style = 'form', bool $explode = true, bool $required = true)

Take query parameter properties and turn it into an array suitable for native http_build_query or GuzzleHttp\Psr7\Query::build.

Parameters

mixed $value

Parameter value

string $paramName

Parameter name

string $openApiType

OpenAPIType eg. array or object

string $style

Parameter serialization style

bool $explode

Parameter explode option

bool $required

Whether query param is required or not

Return Value

array

at line 239
static int|string convertBoolToQueryStringFormat(bool $value)

Convert boolean value to format for query string.

Parameters

bool $value

Boolean value

Return Value

int|string

Boolean value in format

at line 257
static string toHeaderValue(string $value)

Take value and turn it into a string suitable for inclusion in the header. If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601

Parameters

string $value

a string which will be part of the header

Return Value

string

the header string

at line 276
static string toFormValue(string|SplFileObject $value)

Take value and turn it into a string suitable for inclusion in the http body (form parameter). If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601

Parameters

string|SplFileObject $value

the value of the form parameter

Return Value

string

the form string

at line 295
static string toString(string|bool|DateTime $value)

Take value and turn it into a string suitable for inclusion in the parameter. If it's a string, pass through unchanged If it's a datetime object, format it in ISO8601 If it's a boolean, convert it to "true" or "false".

Parameters

string|bool|DateTime $value

the value of the parameter

Return Value

string

the header string

at line 316
static string serializeCollection(array $collection, string $style, bool $allowCollectionFormatMulti = false)

Serialize an array to a string.

Parameters

array $collection

collection to serialize to a string

string $style

the format use for serialization (csv, ssv, tsv, pipes, multi)

bool $allowCollectionFormatMulti

allow collection format to be a multidimensional array

Return Value

string

at line 353
static object|array|null deserialize(mixed $data, string $class, string[] $httpHeaders = null)

Deserialize a JSON string into an object

Parameters

mixed $data

object or primitive to be deserialized

string $class

class name is passed as a string

string[] $httpHeaders

HTTP headers

Return Value

object|array|null

a single or an array of $class instances

at line 509
static string buildQuery(array|object $data, string $numeric_prefix = '', string|null $arg_separator = null, int $encoding_type = \PHP_QUERY_RFC3986)

Native http_build_query wrapper.

Parameters

array|object $data

May be an array or object containing properties.

string $numeric_prefix

If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only.

string|null $arg_separator

arg_separator.output is used to separate arguments but may be overridden by specifying this parameter.

int $encoding_type

Encoding type. By default, PHP_QUERY_RFC1738.

Return Value

string

See also

https://www.php.net/manual/en/function.http-build-query