Mailgun\Deserializer\ArrayDeserializer::deserialize PHP Method

deserialize() public method

public deserialize ( Psr\Http\Message\ResponseInterface $response, string $class ) : array
$response Psr\Http\Message\ResponseInterface
$class string
return array
    public function deserialize(ResponseInterface $response, $class)
    {
        $body = $response->getBody()->__toString();
        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
            throw new DeserializeException('The ArrayDeserializer cannot deserialize response with Content-Type:' . $response->getHeaderLine('Content-Type'));
        }
        $content = 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()));
        }
        return $content;
    }
ArrayDeserializer