Open mstfblci opened 2 months ago
This could be really useful; in a lot of my Connectors, I do things like this:
public function hasRequestFailed(Response $response): ?bool
{
// if psr response is json
$contentType = $response->getPsrResponse()->getHeader('Content-Type');
if (in_array('application/json', $contentType)) {
return ! empty($response->json('errors'));
}
return null;
}
This PR would simplify it like this:
public function hasRequestFailed(Response $response): ?bool
{
if ($response->isJson()) {
return ! empty($response->json('errors'));
}
return null;
}
I would argue, though, that I prefer a more strict comparison than str_contains()
proposed in this PR.
@SRWieZ Thank you for your support.
Two new functions have been added to check if the response return is json or xml