Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 
1441 ariadna 14
    public function __construct(?int $truncateAt = null)
1 efrain 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
1441 ariadna 25
            ? Psr7\Message::bodySummary($message)
26
            : Psr7\Message::bodySummary($message, $this->truncateAt);
1 efrain 27
    }
28
}