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

QueryEvent   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 26
ccs 15
cts 15
cp 1
rs 10
c 3
b 2
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeQueryDTO() 0 19 1
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
}