forked from krowinski/php-mysql-replication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventInfo.php
102 lines (84 loc) · 2.02 KB
/
EventInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
declare(strict_types=1);
namespace MySQLReplication\Event;
use JsonSerializable;
use MySQLReplication\BinLog\BinLogCurrent;
use MySQLReplication\Util\JsonSerializableTrait;
class EventInfo implements JsonSerializable
{
use JsonSerializableTrait;
private $timestamp;
private $type;
private $id;
private $size;
private $pos;
private $flag;
private $checkSum;
private $sizeNoHeader;
private $dateTime;
private $binLogCurrent;
public function __construct(
int $timestamp,
int $type,
int $id,
int $size,
int $pos,
int $flag,
bool $checkSum,
BinLogCurrent $binLogCurrent
) {
$this->timestamp = $timestamp;
$this->type = $type;
$this->id = $id;
$this->size = $size;
$this->pos = $pos;
$this->flag = $flag;
$this->checkSum = $checkSum;
$this->binLogCurrent = $binLogCurrent;
if ($pos > 0) {
$this->binLogCurrent->setBinLogPosition($pos);
}
}
public function getBinLogCurrent(): BinLogCurrent
{
return $this->binLogCurrent;
}
public function getDateTime(): string
{
if (empty($this->dateTime)) {
$this->dateTime = date('c', $this->timestamp);
}
return $this->dateTime;
}
public function getSizeNoHeader(): int
{
if (empty($this->sizeNoHeader)) {
$this->sizeNoHeader = (true === $this->checkSum ? $this->size - 23 : $this->size - 19);
}
return $this->sizeNoHeader;
}
public function getTimestamp(): int
{
return $this->timestamp;
}
public function getType(): int
{
return $this->type;
}
public function getId(): int
{
return $this->id;
}
public function getSize(): int
{
return $this->size;
}
public function getPos(): int
{
return $this->pos;
}
public function getFlag(): int
{
return $this->flag;
}
}