MariaDbGtidLogDTO::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 10
ccs 0
cts 9
cp 0
crap 2
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 MariaDbGtidLogDTO extends EventDTO
10
{
11
    private $type = ConstEventsNames::MARIADB_GTID;
12
    private $flag;
13
    private $domainId;
14
    private $mariaDbGtid;
15
16
    public function __construct(
17
        EventInfo $eventInfo,
18
        int $flag,
19
        int $domainId,
20
        string $mariaDbGtid
21
    ) {
22
        parent::__construct($eventInfo);
23
24
        $this->flag = $flag;
25
        $this->domainId = $domainId;
26
        $this->mariaDbGtid = $mariaDbGtid;
27
    }
28
29
    public function __toString(): string
30
    {
31
        return PHP_EOL .
32
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
33
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
34
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
35
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
36
            'Flag: ' . var_export($this->flag, true) . PHP_EOL .
37
            'Domain Id: ' . $this->domainId . PHP_EOL .
38
            'Sequence Number: ' . $this->mariaDbGtid . PHP_EOL;
39
    }
40
41
42
    public function getType(): string
43
    {
44
        return $this->type;
45
    }
46
47
    #[\ReturnTypeWillChange]
48
    public function jsonSerialize()
49
    {
50
        return get_object_vars($this);
51
    }
52
53
    public function getFlag(): int
54
    {
55
        return $this->flag;
56
    }
57
58
    public function getMariaDbGtid(): string
59
    {
60
        return $this->mariaDbGtid;
61
    }
62
63
    public function getDomainId(): int
64
    {
65
        return $this->domainId;
66
    }
67
}
68