QueryEvent   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 2 Features 0
Metric Value
eloc 16
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 10
c 6
b 2
f 0
wmc 1

1 Method

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