RotateEvent::makeRotateEventDTO()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 1
rs 9.9666
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace MySQLReplication\Event;
5
6
use MySQLReplication\BinLog\BinLogServerInfo;
7
use MySQLReplication\Event\DTO\RotateDTO;
8
9
/**
10
 * @see https://dev.mysql.com/doc/internals/en/rotate-event.html
11
 */
12
class RotateEvent extends EventCommon
13
{
14 1
    public function makeRotateEventDTO(): RotateDTO
15
    {
16 1
        $binFilePos = (int)$this->binaryDataReader->readUInt64();
17 1
        $binFileName = $this->binaryDataReader->read(
18 1
            $this->eventInfo->getSizeNoHeader() - $this->getSizeToRemoveByVersion()
19
        );
20
21 1
        $this->eventInfo->getBinLogCurrent()->setBinLogPosition($binFilePos);
22 1
        $this->eventInfo->getBinLogCurrent()->setBinFileName($binFileName);
23
24 1
        return new RotateDTO(
25 1
            $this->eventInfo,
26
            $binFilePos,
27
            $binFileName
28
        );
29
    }
30
31 1
    private function getSizeToRemoveByVersion(): int
32
    {
33 1
        if (BinLogServerInfo::isMariaDb() && BinLogServerInfo::getRevision() <= 10) {
34
            return 0;
35
        }
36
37 1
        return 8;
38
    }
39
}