PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
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 1.2.9 All 35 releases
← All changes | includes/sdk/s3/Aws/HashingStream.php +10 -8 1.2.31.4.1 View file →
@@ -9,8 +9,10 @@
9 9 */
10 10 class HashingStream implements StreamInterface
11 11 {
12 12 use StreamDecoratorTrait;
13 + /** @var StreamInterface */
14 + private $stream;
13 15 /** @var HashInterface */
14 16 private $hash;
15 17 /** @var callable|null */
16 18 private $callback;
@@ -19,15 +21,15 @@
19 21 * @param HashInterface $hash Hash used to calculate checksum.
20 22 * @param callable $onComplete Optional function invoked when the
21 23 * hash calculation is completed.
22 24 */
23 - public function __construct(StreamInterface $stream, HashInterface $hash, callable $onComplete = null)
25 + public function __construct(StreamInterface $stream, HashInterface $hash, ?callable $onComplete = null)
24 26 {
25 27 $this->stream = $stream;
26 28 $this->hash = $hash;
27 29 $this->callback = $onComplete;
28 30 }
29 - public function read($length)
31 + public function read($length) : string
30 32 {
31 33 $data = $this->stream->read($length);
32 34 $this->hash->update($data);
33 35 if ($this->eof()) {
@@ -37,14 +39,14 @@
37 39 }
38 40 }
39 41 return $data;
40 42 }
41 - public function seek($offset, $whence = \SEEK_SET)
43 + public function seek($offset, $whence = \SEEK_SET) : void
42 44 {
43 - if ($offset === 0) {
44 - $this->hash->reset();
45 - return $this->stream->seek($offset);
45 + // Seeking arbitrarily is not supported.
46 + if ($offset !== 0) {
47 + return;
46 48 }
47 - // Seeking arbitrarily is not supported.
48 - return \false;
49 + $this->hash->reset();
50 + $this->stream->seek($offset);
49 51 }
50 52 }