RotateEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 26
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSizeToRemoveByVersion() 0 7 3
A makeRotateEventDTO() 0 14 1
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
}