GTIDLogDTO   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 52
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getGtid() 0 3 1
A isCommit() 0 3 1
A getType() 0 3 1
A jsonSerialize() 0 3 1
A __construct() 0 9 1
A __toString() 0 9 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 GTIDLogDTO extends EventDTO
10
{
11
    private $commit;
12
    private $gtid;
13
    private $type = ConstEventsNames::GTID;
14
15
    /**
16
     * GTIDLogEventDTO constructor.
17
     * @param EventInfo $eventInfo
18
     * @param bool $commit
19
     * @param string $gtid
20
     */
21
    public function __construct(
22
        EventInfo $eventInfo,
23
        bool $commit,
24
        string $gtid
25
    ) {
26
        parent::__construct($eventInfo);
27
28
        $this->commit = $commit;
29
        $this->gtid = $gtid;
30
    }
31
32
    public function isCommit(): bool
33
    {
34
        return $this->commit;
35
    }
36
37
    public function getGtid(): string
38
    {
39
        return $this->gtid;
40
    }
41
42
    public function getType(): string
43
    {
44
        return $this->type;
45
    }
46
47
    public function __toString(): string
48
    {
49
        return PHP_EOL .
50
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
51
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
52
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
53
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
54
            'Commit: ' . var_export($this->commit, true) . PHP_EOL .
55
            'GTID NEXT: ' . $this->gtid . PHP_EOL;
56
    }
57
58
    public function jsonSerialize()
59
    {
60
        return get_object_vars($this);
61
    }
62
}