PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/guzzlehttp/psr7/src/LimitStream.php +13 -14 1.2.13 → 1.4.2 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2
3 3 declare (strict_types=1);
4 -namespace Dudlewebs\WPMCS\GuzzleHttp\Psr7;
4 +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7;
5 5
6 -use Dudlewebs\WPMCS\Psr\Http\Message\StreamInterface;
6 +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\StreamInterface;
7 7 /**
8 8 * Decorator used to return only a subset of a stream.
9 9 */
10 10 final class LimitStream implements StreamInterface
@@ -28,9 +28,9 @@
28 28 $this->stream = $stream;
29 29 $this->setLimit($limit);
30 30 $this->setOffset($offset);
31 31 }
32 - public function eof(): bool
32 + public function eof() : bool
33 33 {
34 34 // Always return true if the underlying stream is EOF
35 35 if ($this->stream->eof()) {
36 36 return \true;
@@ -43,25 +43,24 @@
43 43 }
44 44 /**
45 45 * Returns the size of the limited subset of data
46 46 */
47 - public function getSize(): ?int
47 + public function getSize() : ?int
48 48 {
49 - if (null === $length = $this->stream->getSize()) {
49 + if (null === ($length = $this->stream->getSize())) {
50 50 return null;
51 51 } elseif ($this->limit === -1) {
52 52 return $length - $this->offset;
53 - } else {
54 - return min($this->limit, $length - $this->offset);
55 53 }
54 + return \min($this->limit, $length - $this->offset);
56 55 }
57 56 /**
58 57 * Allow for a bounded seek on the read limited stream
59 58 */
60 - public function seek($offset, $whence = \SEEK_SET): void
59 + public function seek($offset, $whence = \SEEK_SET) : void
61 60 {
62 61 if ($whence !== \SEEK_SET || $offset < 0) {
63 - throw new \RuntimeException(sprintf('Cannot seek to offset %s with whence %s', $offset, $whence));
62 + throw new \RuntimeException(\sprintf('Cannot seek to offset %s with whence %s', $offset, $whence));
64 63 }
65 64 $offset += $this->offset;
66 65 if ($this->limit !== -1) {
67 66 if ($offset > $this->offset + $this->limit) {
@@ -72,9 +71,9 @@
72 71 }
73 72 /**
74 73 * Give a relative tell()
75 74 */
76 - public function tell(): int
75 + public function tell() : int
77 76 {
78 77 return $this->stream->tell() - $this->offset;
79 78 }
80 79 /**
@@ -83,9 +82,9 @@
83 82 * @param int $offset Offset to seek to and begin byte limiting from
84 83 *
85 84 * @throws \RuntimeException if the stream cannot be seeked.
86 85 */
87 - public function setOffset(int $offset): void
86 + public function setOffset(int $offset) : void
88 87 {
89 88 $current = $this->stream->tell();
90 89 if ($current !== $offset) {
91 90 // If the stream cannot seek to the offset position, then read to it
@@ -105,13 +104,13 @@
105 104 *
106 105 * @param int $limit Number of bytes to allow to be read from the stream.
107 106 * Use -1 for no limit.
108 107 */
109 - public function setLimit(int $limit): void
108 + public function setLimit(int $limit) : void
110 109 {
111 110 $this->limit = $limit;
112 111 }
113 - public function read($length): string
112 + public function read($length) : string
114 113 {
115 114 if ($this->limit === -1) {
116 115 return $this->stream->read($length);
117 116 }
@@ -120,9 +119,9 @@
120 119 $remaining = $this->offset + $this->limit - $this->stream->tell();
121 120 if ($remaining > 0) {
122 121 // Only return the amount of requested data, ensuring that the byte
123 122 // limit is not exceeded
124 - return $this->stream->read(min($remaining, $length));
123 + return $this->stream->read(\min($remaining, $length));
125 124 }
126 125 return '';
127 126 }
128 127 }