woocommerce-pos
/
vendor_prefixed
/
sentry
/
sentry
/
src
/
DataCollection
/
Psr7MessageBodySource.php
Psr7MessageBodySource.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.26, at vendor_prefixed/sentry/sentry/src/DataCollection/Psr7MessageBodySource.php
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace WCPOS\Vendor\Sentry\DataCollection; |
| 5 | |
| 6 | use WCPOS\Vendor\Psr\Http\Message\MessageInterface; |
| 7 | /** |
| 8 | * @internal |
| 9 | */ |
| 10 | final class Psr7MessageBodySource implements HttpBodySourceInterface |
| 11 | { |
| 12 | /** |
| 13 | * @var MessageInterface |
| 14 | */ |
| 15 | private $message; |
| 16 | public function __construct(MessageInterface $message) |
| 17 | { |
| 18 | $this->message = $message; |
| 19 | } |
| 20 | public function getKnownLength() : ?int |
| 21 | { |
| 22 | $length = $this->message->getHeaderLine('Content-Length'); |
| 23 | return \is_numeric($length) ? (int) $length : null; |
| 24 | } |
| 25 | public function getContentType() : string |
| 26 | { |
| 27 | return $this->message->getHeaderLine('Content-Type'); |
| 28 | } |
| 29 | public function read(int $limit) : ?string |
| 30 | { |
| 31 | $stream = $this->message->getBody(); |
| 32 | $size = $stream->getSize(); |
| 33 | if ($limit !== -1 && $size !== null && $size > $limit) { |
| 34 | return null; |
| 35 | } |
| 36 | return Psr7BodyReader::read($stream, $limit); |
| 37 | } |
| 38 | } |
| 39 |