PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.2
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / vendor_prefixed / guzzlehttp / psr7 / src / DroppingStream.php

DroppingStream.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.2, at vendor_prefixed/guzzlehttp/psr7/src/DroppingStream.php

39 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
4
5 use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
6 /**
7 * Stream decorator that begins dropping data once the size of the underlying
8 * stream becomes too full.
9 *
10 * @final
11 */
12 class DroppingStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
13 {
14 use StreamDecoratorTrait;
15 private $maxLength;
16 /**
17 * @param StreamInterface $stream Underlying stream to decorate.
18 * @param int $maxLength Maximum size before dropping data.
19 */
20 public function __construct(\YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream, $maxLength)
21 {
22 $this->stream = $stream;
23 $this->maxLength = $maxLength;
24 }
25 public function write($string)
26 {
27 $diff = $this->maxLength - $this->stream->getSize();
28 // Begin returning 0 when the underlying stream is too large.
29 if ($diff <= 0) {
30 return 0;
31 }
32 // Write the stream or a subset of the stream if needed.
33 if (\strlen($string) < $diff) {
34 return $this->stream->write($string);
35 }
36 return $this->stream->write(\substr($string, 0, $diff));
37 }
38 }
39