Passed
Pull Request — master (#19)
by
unknown
03:27
created

MariaDbGtidListDTO::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
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 MariaDbGtidListDTO extends EventDTO
10
{
11
    private $type = ConstEventsNames::MARIADB_GTID_LIST;
12
    private $mariaDbGtidList;
13
14
    public function __construct(
15
        EventInfo $eventInfo,
16
        string $mariaDbGtidList
17
    ) {
18
        parent::__construct($eventInfo);
19
20
        $this->mariaDbGtidList = $mariaDbGtidList;
21
    }
22
23
    public function __toString(): string
24
    {
25
        return PHP_EOL .
26
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
27
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
28
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
29
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
30
            'Global Transaction ID: ' . $this->mariaDbGtidList . PHP_EOL;
31
    }
32
33
34
    public function getType(): string
35
    {
36
        return $this->type;
37
    }
38
39
    #[\ReturnTypeWillChange]
40
    public function jsonSerialize()
41
    {
42
        return get_object_vars($this);
43
    }
44
45
    public function getMariaDbGtidList(): string
46
    {
47
        return $this->mariaDbGtidList;
48
    }
49
50
}
51