ObjectSerializer
in package
ObjectSerializer Class Doc Comment
Tags
Table of Contents
Properties
- $dateTimeFormat : string
Methods
- buildQuery() : string
- Build a query string from an array of key value pairs.
- convertBoolToQueryStringFormat() : int|string
- Convert boolean value to format for query string.
- deserialize() : mixed
- Deserialize a JSON string into an object
- sanitizeFilename() : string
- Sanitize filename by removing path.
- sanitizeForSerialization() : scalar|object|array<string|int, mixed>|null
- Serialize data
- sanitizeTimestamp() : string
- Shorter timestamp microseconds to 6 digits length.
- serializeCollection() : string
- Serialize an array to a string.
- setDateTimeFormat() : void
- Change the date format
- toHeaderValue() : string
- 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
- toPathValue() : string
- Take value and turn it into a string suitable for inclusion in the path, by url-encoding.
- toQueryValue() : array<string|int, mixed>
- Take query parameter properties and turn it into an array suitable for native http_build_query or GuzzleHttp\Psr7\Query::build.
- toString() : string
- 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".
- deserializeAnyOf() : mixed
- Deserialize data into one of the member types of an `anyOf` schema.
- deserializeOneOf() : mixed
- Deserialize data into one of the member types of a `oneOf` schema.
- isEmptyValue() : bool
- Checks if a value is empty, based on its OpenAPI type.
- isPrimitiveTypeCompatible() : bool
- Returns true when $data's PHP type is compatible with the OpenAPI primitive $type.
- toArrayRecursive() : mixed
- Convert objects into arrays, recursively.
Properties
$dateTimeFormat
private
static string
$dateTimeFormat
= \DateTimeInterface::ATOM
Methods
buildQuery()
Build a query string from an array of key value pairs.
public
static buildQuery(array<string|int, mixed> $params[, int|false $encoding = PHP_QUERY_RFC3986 ][, Configuration|null $config = null ]) : string
This function can use the return value of parse() to build a query
string. This function does not modify the provided keys when an array is
encountered (like http_build_query() would).
Parameters
- $params : array<string|int, mixed>
-
Query string parameters.
- $encoding : int|false = PHP_QUERY_RFC3986
-
Set to false to not encode, PHP_QUERY_RFC3986 to encode using RFC3986, or PHP_QUERY_RFC1738 to encode using RFC1738.
- $config : Configuration|null = null
-
Configuration that defines the format of boolean values, the default configuration is used if null
Return values
stringconvertBoolToQueryStringFormat()
Convert boolean value to format for query string.
public
static convertBoolToQueryStringFormat(bool $value[, Configuration|null $config = null ]) : int|string
Parameters
- $value : bool
-
Boolean value
- $config : Configuration|null = null
-
Configuration that defines the format, the default configuration is used if null
Return values
int|string —Boolean value in format
deserialize()
Deserialize a JSON string into an object
public
static deserialize(mixed $data, string $class[, array<string|int, string>|null $httpHeaders = null ]) : mixed
Parameters
- $data : mixed
-
object or primitive to be deserialized
- $class : string
-
class name is passed as a string
- $httpHeaders : array<string|int, string>|null = null
-
HTTP headers
Return values
mixed —a single or an array of $class instances
sanitizeFilename()
Sanitize filename by removing path.
public
static sanitizeFilename(string $filename) : string
e.g. ../../sun.gif becomes sun.gif
Parameters
- $filename : string
-
filename to be sanitized
Return values
string —the sanitized filename
sanitizeForSerialization()
Serialize data
public
static sanitizeForSerialization(mixed $data[, string|null $type = null ][, string|null $format = null ]) : scalar|object|array<string|int, mixed>|null
Parameters
- $data : mixed
-
the data to serialize
- $type : string|null = null
-
the OpenAPIToolsType of the data
- $format : string|null = null
-
the format of the OpenAPITools type of the data
Return values
scalar|object|array<string|int, mixed>|null —serialized form of $data
sanitizeTimestamp()
Shorter timestamp microseconds to 6 digits length.
public
static sanitizeTimestamp(string $timestamp) : string
Parameters
- $timestamp : string
-
Original timestamp
Return values
string —the shorten timestamp
serializeCollection()
Serialize an array to a string.
public
static serializeCollection(array<string|int, mixed> $collection, string $style[, bool $allowCollectionFormatMulti = false ]) : string
Parameters
- $collection : array<string|int, mixed>
-
collection to serialize to a string
- $style : string
-
the format use for serialization (csv, ssv, tsv, pipes, multi)
- $allowCollectionFormatMulti : bool = false
-
allow collection format to be a multidimensional array
Return values
stringsetDateTimeFormat()
Change the date format
public
static setDateTimeFormat(string $format) : void
Parameters
- $format : string
-
the new date format to use
toHeaderValue()
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
public
static toHeaderValue(string $value) : string
Parameters
- $value : string
-
a string which will be part of the header
Return values
string —the header string
toPathValue()
Take value and turn it into a string suitable for inclusion in the path, by url-encoding.
public
static toPathValue(string $value) : string
Parameters
- $value : string
-
a string which will be part of the path
Return values
string —the serialized object
toQueryValue()
Take query parameter properties and turn it into an array suitable for native http_build_query or GuzzleHttp\Psr7\Query::build.
public
static toQueryValue(mixed $value, string $paramName[, string $openApiType = 'string' ][, string $style = 'form' ][, bool $explode = true ][, bool $required = true ][, Configuration|null $config = null ]) : array<string|int, mixed>
Parameters
- $value : mixed
-
Parameter value
- $paramName : string
-
Parameter name
- $openApiType : string = 'string'
-
OpenAPIType e.g. array or object
- $style : string = 'form'
-
Parameter serialization style
- $explode : bool = true
-
Parameter explode option
- $required : bool = true
-
Whether query param is required or not
- $config : Configuration|null = null
-
Configuration that defines the format of boolean values, the default configuration is used if null
Return values
array<string|int, mixed>toString()
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".
public
static toString(string|bool|DateTime $value) : string
Parameters
- $value : string|bool|DateTime
-
the value of the parameter
Return values
string —the header string
deserializeAnyOf()
Deserialize data into one of the member types of an `anyOf` schema.
private
static deserializeAnyOf(mixed $data, string $class, array<string|int, string>|null $httpHeaders) : mixed
When the schema declares a discriminator, its value selects the member type directly. Otherwise each member type is tried in turn and the first one that yields a valid model (or a non-null primitive) is returned.
Parameters
- $data : mixed
-
the decoded data to resolve to a member type
- $class : string
-
a class name implementing AnyOfInterface
- $httpHeaders : array<string|int, string>|null
-
HTTP headers
Return values
mixed —an instance of one of the anyOf member types
deserializeOneOf()
Deserialize data into one of the member types of a `oneOf` schema.
private
static deserializeOneOf(mixed $data, string $class, array<string|int, string>|null $httpHeaders) : mixed
When the schema declares a discriminator, its value selects the member type directly. Otherwise each member type is tried in turn and the first one that yields a valid model (or a non-null primitive) is returned.
Parameters
- $data : mixed
-
the decoded data to resolve to a member type
- $class : string
-
a class name implementing OneOfInterface
- $httpHeaders : array<string|int, string>|null
-
HTTP headers
Return values
mixed —an instance of one of the oneOf member types
isEmptyValue()
Checks if a value is empty, based on its OpenAPI type.
private
static isEmptyValue(mixed $value, string $openApiType) : bool
Parameters
- $value : mixed
- $openApiType : string
Return values
bool —true if $value is empty
isPrimitiveTypeCompatible()
Returns true when $data's PHP type is compatible with the OpenAPI primitive $type.
private
static isPrimitiveTypeCompatible(mixed $data, string $type) : bool
Prevents settype() coercion (e.g. "abc" → 0 for integer) from producing a false match when iterating over oneOf/anyOf candidate types. Non-primitive types always return true and are validated downstream by ModelInterface::valid().
Parameters
- $data : mixed
- $type : string
Return values
booltoArrayRecursive()
Convert objects into arrays, recursively.
private
static toArrayRecursive(mixed $data) : mixed
sanitizeForSerialization() returns an object per model, but query parameters are flattened from arrays.
Parameters
- $data : mixed
Return values
mixed —the data with every object converted to an array