Mailgun\Deserializer\ModelDeserializer::deserialize PHP Метод

deserialize() публичный Метод

public deserialize ( Psr\Http\Message\ResponseInterface $response, string $class ) : Psr\Http\Message\ResponseInterface
$response Psr\Http\Message\ResponseInterface
$class string
Результат Psr\Http\Message\ResponseInterface
    public function deserialize(ResponseInterface $response, $class)
    {
        $body = $response->getBody()->__toString();
        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
            throw new DeserializeException('The ModelDeserializer cannot deserialize response with Content-Type:' . $response->getHeaderLine('Content-Type'));
        }
        $data = json_decode($body, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new DeserializeException(sprintf('Error (%d) when trying to json_decode response', json_last_error()));
        }
        if (is_subclass_of($class, ApiResponse::class)) {
            $object = call_user_func($class . '::create', $data);
        } else {
            $object = new $class($data);
        }
        return $object;
    }
ModelDeserializer