YoastSEO_Vendor\GuzzleHttp\Psr7
get_message_body_summary() Yoast 1.0
Get a short summary of the message body
Will return null if the response is not printable.
Хуков нет.
Возвращает
null/Строку.
Использование
get_message_body_summary( \YoastSEO_Vendor\Psr\Http\Message\MessageInterface $message, $truncateAt );
- $message(Messageчислоerface) (обязательный)
- The message to get the body summary
- $truncateAt(число)
- The maximum allowed size of the summary
По умолчанию: 120
Код get_message_body_summary() get message body summary Yoast 15.6.2
function get_message_body_summary(\YoastSEO_Vendor\Psr\Http\Message\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;
}