Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 50... Línea 50...
50
        8 => 'decodeTimestamp',
50
        8 => 'decodeTimestamp',
51
        9 => 'decodeUuid',
51
        9 => 'decodeUuid',
52
    ];
52
    ];
Línea 53... Línea 53...
53
 
53
 
54
    /** @var StreamInterface Stream of eventstream shape to parse. */
54
    /** @var StreamInterface Stream of eventstream shape to parse. */
Línea 55... Línea 55...
55
    private $stream;
55
    protected $stream;
56
 
56
 
Línea 57... Línea 57...
57
    /** @var array Currently parsed event. */
57
    /** @var array Currently parsed event. */
58
    private $currentEvent;
58
    protected $currentEvent;
Línea 59... Línea 59...
59
 
59
 
60
    /** @var int Current in-order event key. */
60
    /** @var int Current in-order event key. */
Línea 61... Línea 61...
61
    private $key;
61
    protected $key;
62
 
62
 
Línea 63... Línea 63...
63
    /** @var resource|\HashContext CRC32 hash context for event validation */
63
    /** @var resource|\HashContext CRC32 hash context for event validation */
64
    private $hashContext;
64
    protected $hashContext;
65
 
65
 
66
    /** @var int $currentPosition */
66
    /** @var int $currentPosition */
Línea 75... Línea 75...
75
    {
75
    {
76
        $this->stream = $stream;
76
        $this->stream = $stream;
77
        $this->rewind();
77
        $this->rewind();
78
    }
78
    }
Línea 79... Línea 79...
79
 
79
 
80
    private function parseHeaders($headerBytes)
80
    protected function parseHeaders($headerBytes)
81
    {
81
    {
82
        $headers = [];
82
        $headers = [];
Línea 83... Línea 83...
83
        $bytesRead = 0;
83
        $bytesRead = 0;
Línea 100... Línea 100...
100
        }
100
        }
Línea 101... Línea 101...
101
 
101
 
102
        return [$headers, $bytesRead];
102
        return [$headers, $bytesRead];
Línea 103... Línea 103...
103
    }
103
    }
104
 
104
 
105
    private function parsePrelude()
105
    protected function parsePrelude()
106
    {
106
    {
Línea 107... Línea 107...
107
        $prelude = [];
107
        $prelude = [];
Línea 125... Línea 125...
125
        }
125
        }
Línea 126... Línea 126...
126
 
126
 
127
        return [$prelude, $bytesRead];
127
        return [$prelude, $bytesRead];
Línea -... Línea 128...
-
 
128
    }
-
 
129
 
-
 
130
    /**
-
 
131
     * This method decodes an event from the stream.
-
 
132
     *
128
    }
133
     * @return array
129
 
134
     */
130
    private function parseEvent()
135
    protected function parseEvent()
Línea 131... Línea 136...
131
    {
136
    {
132
        $event = [];
137
        $event = [];
Línea 185... Línea 190...
185
    public function key()
190
    public function key()
186
    {
191
    {
187
        return $this->key;
192
        return $this->key;
188
    }
193
    }
Línea -... Línea 194...
-
 
194
 
-
 
195
    /**
-
 
196
     * @return void
189
 
197
     */
190
    #[\ReturnTypeWillChange]
198
    #[\ReturnTypeWillChange]
191
    public function next()
199
    public function next()
192
    {
200
    {
193
        $this->currentPosition = $this->stream->tell();
201
        $this->currentPosition = $this->stream->tell();
194
        if ($this->valid()) {
202
        if ($this->valid()) {
195
            $this->key++;
203
            $this->key++;
196
            $this->currentEvent = $this->parseEvent();
204
            $this->currentEvent = $this->parseEvent();
197
        }
205
        }
Línea -... Línea 206...
-
 
206
    }
-
 
207
 
-
 
208
    /**
198
    }
209
     * @return void
199
 
210
     */
200
    #[\ReturnTypeWillChange]
211
    #[\ReturnTypeWillChange]
201
    public function rewind()
212
    public function rewind()
202
    {
213
    {
Línea 215... Línea 226...
215
        return $this->currentPosition < $this->stream->getSize();
226
        return $this->currentPosition < $this->stream->getSize();
216
    }
227
    }
Línea 217... Línea 228...
217
 
228
 
Línea 218... Línea 229...
218
    // Decoding Utilities
229
    // Decoding Utilities
219
 
230
 
220
    private function readAndHashBytes($num)
231
    protected function readAndHashBytes($num)
221
    {
232
    {
222
        $bytes = $this->stream->read($num);
233
        $bytes = $this->stream->read($num);
223
        hash_update($this->hashContext, $bytes);
234
        hash_update($this->hashContext, $bytes);