ResponseSerializer
in package
Handles serialization and deserialization of PSR-7 Response objects.
Converts Response objects to arrays for cache storage and reconstructs Response objects from cached arrays.
Table of Contents
Properties
- $maxBodySize : int
Methods
- __construct() : mixed
- Constructor.
- deserialize() : ResponseInterface|null
- Deserialize an array back to a PSR-7 Response.
- serialize() : array<string, mixed>
- Serialize a PSR-7 Response to an array.
Properties
$maxBodySize
private
int
$maxBodySize
Maximum body size to cache (1MB default)
Methods
__construct()
Constructor.
public
__construct([int $maxBodySize = 1048576 ]) : mixed
Parameters
- $maxBodySize : int = 1048576
-
Maximum response body size to cache in bytes
deserialize()
Deserialize an array back to a PSR-7 Response.
public
deserialize(array<string, mixed> $data) : ResponseInterface|null
Parameters
- $data : array<string, mixed>
-
The serialized response data
Return values
ResponseInterface|null —The reconstructed response or null if not cacheable
serialize()
Serialize a PSR-7 Response to an array.
public
serialize(ResponseInterface $response) : array<string, mixed>
Parameters
- $response : ResponseInterface
-
The response to serialize
Return values
array<string, mixed> —The serialized response data