function get_message_body_summary in Auth0 Single Sign On 8.2
Get a short summary of the message body
Will return `null` if the response is not printable.
Parameters
MessageInterface $message The message to get the body summary:
int $truncateAt The maximum allowed size of the summary:
Return value
null|string
File
- vendor/
guzzlehttp/ psr7/ src/ functions.php, line 853
Namespace
GuzzleHttp\Psr7Code
function get_message_body_summary(MessageInterface $message, $truncateAt = 120) {
$body = $message
->getBody();
if (!$body
->isSeekable() || !$body
->isReadable()) {
return null;
}
$size = $body
->getSize();
if ($size === 0) {
return null;
}
$summary = $body
->read($truncateAt);
$body
->rewind();
if ($size > $truncateAt) {
$summary .= ' (truncated...)';
}
// Matches any printable character, including unicode characters:
// letters, marks, numbers, punctuation, spacing, and separators.
if (preg_match('/[^\\pL\\pM\\pN\\pP\\pS\\pZ\\n\\r\\t]/', $summary)) {
return null;
}
return $summary;
}