forked from krowinski/php-mysql-replication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRowsDTO.php
58 lines (48 loc) · 1.51 KB
/
RowsDTO.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
<?php
declare(strict_types=1);
namespace MySQLReplication\Event\DTO;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Event\RowEvent\TableMap;
use MySQLReplication\Util\JsonSerializableTrait;
abstract class RowsDTO extends EventDTO
{
use JsonSerializableTrait;
private $values;
private $changedRows;
private $tableMap;
public function __construct(
EventInfo $eventInfo,
TableMap $tableMap,
int $changedRows,
array $values
) {
parent::__construct($eventInfo);
$this->changedRows = $changedRows;
$this->values = $values;
$this->tableMap = $tableMap;
}
public function getTableMap(): TableMap
{
return $this->tableMap;
}
public function getChangedRows(): int
{
return $this->changedRows;
}
public function getValues(): array
{
return $this->values;
}
public function __toString(): string
{
return PHP_EOL .
'=== Event ' . $this->getType() . ' === ' . PHP_EOL .
'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
'Table: ' . $this->tableMap->getTable() . PHP_EOL .
'Affected columns: ' . $this->tableMap->getColumnsAmount() . PHP_EOL .
'Changed rows: ' . $this->changedRows . PHP_EOL .
'Values: ' . print_r($this->values, true) . PHP_EOL;
}
}