QueryEvent::makeQueryDTO()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

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