Cookie
2 years ago
Exception
3 years ago
Handler
2 years ago
BodySummarizer.php
3 years ago
BodySummarizerInterface.php
3 years ago
Client.php
3 years ago
ClientInterface.php
3 years ago
ClientTrait.php
3 years ago
HandlerStack.php
3 years ago
MessageFormatter.php
3 years ago
MessageFormatterInterface.php
3 years ago
Middleware.php
3 years ago
Pool.php
3 years ago
PrepareBodyMiddleware.php
3 years ago
RedirectMiddleware.php
3 years ago
RequestOptions.php
3 years ago
RetryMiddleware.php
2 years ago
TransferStats.php
3 years ago
Utils.php
2 years ago
functions.php
3 years ago
functions_include.php
3 years ago
BodySummarizer.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | namespace GuzzleHttp; |
| 4 | |
| 5 | use Psr\Http\Message\MessageInterface; |
| 6 | |
| 7 | final class BodySummarizer implements BodySummarizerInterface |
| 8 | { |
| 9 | /** |
| 10 | * @var int|null |
| 11 | */ |
| 12 | private $truncateAt; |
| 13 | |
| 14 | public function __construct(int $truncateAt = null) |
| 15 | { |
| 16 | $this->truncateAt = $truncateAt; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Returns a summarized message body. |
| 21 | */ |
| 22 | public function summarize(MessageInterface $message): ?string |
| 23 | { |
| 24 | return $this->truncateAt === null |
| 25 | ? \GuzzleHttp\Psr7\Message::bodySummary($message) |
| 26 | : \GuzzleHttp\Psr7\Message::bodySummary($message, $this->truncateAt); |
| 27 | } |
| 28 | } |
| 29 |