RotateDTO   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 30%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 19
c 1
b 1
f 0
dl 0
loc 47
ccs 6
cts 20
cp 0.3
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 9 1
A __construct() 0 9 1
A getNextBinlog() 0 3 1
A getType() 0 3 1
A getPosition() 0 3 1
A jsonSerialize() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace MySQLReplication\Event\DTO;
5
6
use MySQLReplication\Definitions\ConstEventsNames;
7
use MySQLReplication\Event\EventInfo;
8
9
class RotateDTO extends EventDTO
10
{
11
    private $position;
12
    private $nextBinlog;
13
    private $type = ConstEventsNames::ROTATE;
14
15 1
    public function __construct(
16
        EventInfo $eventInfo,
17
        int $position,
18
        string $nextBinlog
19
    ) {
20 1
        parent::__construct($eventInfo);
21
22 1
        $this->position = $position;
23 1
        $this->nextBinlog = $nextBinlog;
24
    }
25
26
    public function getPosition(): int
27
    {
28
        return $this->position;
29
    }
30
31
    public function getNextBinlog(): string
32
    {
33
        return $this->nextBinlog;
34
    }
35
36 1
    public function getType(): string
37
    {
38 1
        return $this->type;
39
    }
40
41
    public function __toString(): string
42
    {
43
        return PHP_EOL .
44
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
45
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
46
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
47
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
48
            'Binlog position: ' . $this->position . PHP_EOL .
49
            'Binlog filename: ' . $this->nextBinlog . PHP_EOL;
50
    }
51
52
    #[\ReturnTypeWillChange]
53
    public function jsonSerialize()
54
    {
55
        return get_object_vars($this);
56
    }
57
}
58