Passed
Pull Request — master (#27)
by kacper
02:45
created

QueryEvent::getSizeToRemoveByVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
1
<?php
2
3
namespace MySQLReplication\Event;
4
5
use MySQLReplication\BinaryDataReader\BinaryDataReaderException;
6
use MySQLReplication\BinLog\BinLogServerInfo;
7
use MySQLReplication\Event\DTO\QueryDTO;
8
9
/**
10
 * Class QueryEvent
11
 * @package MySQLReplication\Event
12
 * @see https://dev.mysql.com/doc/internals/en/query-event.html
13
 */
14
class QueryEvent extends EventCommon
15
{
16
    /**
17
     * @return QueryDTO
18
     * @throws BinaryDataReaderException
19
     */
20 54
    public function makeQueryDTO()
21
    {
22 54
        $this->binaryDataReader->advance(4);
23 54
        $executionTime = $this->binaryDataReader->readUInt32();
24 54
        $schemaLength = $this->binaryDataReader->readUInt8();
25 54
        $this->binaryDataReader->advance(2);
26 54
        $statusVarsLength = $this->binaryDataReader->readUInt16();
27 54
        $this->binaryDataReader->advance($statusVarsLength);
28 54
        $schema = $this->binaryDataReader->read($schemaLength);
29 54
        $this->binaryDataReader->advance(1);
30 54
        $query = $this->binaryDataReader->read($this->eventInfo->getSizeNoHeader() - 13 - $statusVarsLength - $schemaLength - 1);
31
32 54
        return new QueryDTO(
33 54
            $this->eventInfo,
34 54
            $schema,
35 54
            $executionTime,
36
            $query
37 54
        );
38
    }
39
}