Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 27... Línea 27...
27
     *                                    hash calculation is completed.
27
     *                                    hash calculation is completed.
28
     */
28
     */
29
    public function __construct(
29
    public function __construct(
30
        StreamInterface $stream,
30
        StreamInterface $stream,
31
        HashInterface $hash,
31
        HashInterface $hash,
32
        callable $onComplete = null
32
        ?callable $onComplete = null
33
    ) {
33
    ) {
34
        $this->stream = $stream;
34
        $this->stream = $stream;
35
        $this->hash = $hash;
35
        $this->hash = $hash;
36
        $this->callback = $onComplete;
36
        $this->callback = $onComplete;
37
    }
37
    }
Línea 38... Línea 38...
38
 
38
 
39
    public function read($length)
39
    public function read($length): string
40
    {
40
    {
41
        $data = $this->stream->read($length);
41
        $data = $this->stream->read($length);
42
        $this->hash->update($data);
42
        $this->hash->update($data);
43
        if ($this->eof()) {
43
        if ($this->eof()) {
Línea 48... Línea 48...
48
        }
48
        }
Línea 49... Línea 49...
49
 
49
 
50
        return $data;
50
        return $data;
Línea 51... Línea 51...
51
    }
51
    }
52
 
52
 
-
 
53
    public function seek($offset, $whence = SEEK_SET): void
53
    public function seek($offset, $whence = SEEK_SET)
54
    {
54
    {
55
        // Seeking arbitrarily is not supported.
55
        if ($offset === 0) {
-
 
56
            $this->hash->reset();
56
        if ($offset !== 0) {
Línea 57... Línea 57...
57
            return $this->stream->seek($offset);
57
            return;
58
        }
58
        }
59
 
59
 
60
        // Seeking arbitrarily is not supported.
60
        $this->hash->reset();