| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +declare (strict_types=1); | |
| 3 | 4 | namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7; |
| 4 | 5 | |
| 5 | 6 | use Dudlewebs\WPMCS\s3\Psr\Http\Message\StreamInterface; |
| 6 | 7 | /** |
| @@ -5,25 +6,26 @@ | ||
| 5 | 6 | use Dudlewebs\WPMCS\s3\Psr\Http\Message\StreamInterface; |
| 6 | 7 | /** |
| 7 | 8 | * Stream decorator that begins dropping data once the size of the underlying |
| 8 | 9 | * stream becomes too full. |
| 9 | - * | |
| 10 | - * @final | |
| 11 | 10 | */ |
| 12 | -class DroppingStream implements StreamInterface | |
| 11 | +final class DroppingStream implements StreamInterface | |
| 13 | 12 | { |
| 14 | 13 | use StreamDecoratorTrait; |
| 14 | + /** @var int */ | |
| 15 | 15 | private $maxLength; |
| 16 | + /** @var StreamInterface */ | |
| 17 | + private $stream; | |
| 16 | 18 | /** |
| 17 | 19 | * @param StreamInterface $stream Underlying stream to decorate. |
| 18 | 20 | * @param int $maxLength Maximum size before dropping data. |
| 19 | 21 | */ |
| 20 | - public function __construct(StreamInterface $stream, $maxLength) | |
| 22 | + public function __construct(StreamInterface $stream, int $maxLength) | |
| 21 | 23 | { |
| 22 | 24 | $this->stream = $stream; |
| 23 | 25 | $this->maxLength = $maxLength; |
| 24 | 26 | } |
| 25 | - public function write($string) | |
| 27 | + public function write($string) : int | |
| 26 | 28 | { |
| 27 | 29 | $diff = $this->maxLength - $this->stream->getSize(); |
| 28 | 30 | // Begin returning 0 when the underlying stream is too large. |
| 29 | 31 | if ($diff <= 0) { |