Passed
Pull Request — master (#6)
by Moln
05:27
created

RotateDTO::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 9
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
    public function jsonSerialize()
53
    {
54
        return get_object_vars($this);
55
    }
56
}