1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace MySQLReplication\Event\DTO; |
||
5 | |||
6 | use MySQLReplication\Event\EventInfo; |
||
7 | use MySQLReplication\Event\RowEvent\TableMap; |
||
8 | |||
9 | abstract class RowsDTO extends EventDTO |
||
10 | { |
||
11 | private $values; |
||
12 | private $changedRows; |
||
13 | private $tableMap; |
||
14 | |||
15 | 53 | public function __construct( |
|
16 | EventInfo $eventInfo, |
||
17 | TableMap $tableMap, |
||
18 | int $changedRows, |
||
19 | array $values |
||
20 | ) { |
||
21 | 53 | parent::__construct($eventInfo); |
|
22 | |||
23 | 53 | $this->changedRows = $changedRows; |
|
24 | 53 | $this->values = $values; |
|
25 | 53 | $this->tableMap = $tableMap; |
|
26 | 53 | } |
|
27 | |||
28 | 1 | public function getTableMap(): TableMap |
|
29 | { |
||
30 | 1 | return $this->tableMap; |
|
31 | } |
||
32 | |||
33 | 1 | public function getChangedRows(): int |
|
34 | { |
||
35 | 1 | return $this->changedRows; |
|
36 | } |
||
37 | |||
38 | 53 | public function getValues(): array |
|
39 | { |
||
40 | 53 | return $this->values; |
|
41 | } |
||
42 | |||
43 | public function __toString(): string |
||
44 | { |
||
45 | return PHP_EOL . |
||
46 | '=== Event ' . $this->getType() . ' === ' . PHP_EOL . |
||
47 | 'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL . |
||
48 | 'Log position: ' . $this->eventInfo->getPos() . PHP_EOL . |
||
49 | 'Event size: ' . $this->eventInfo->getSize() . PHP_EOL . |
||
50 | 'Table: ' . $this->tableMap->getTable() . PHP_EOL . |
||
51 | 'Affected columns: ' . $this->tableMap->getColumnsAmount() . PHP_EOL . |
||
52 | 'Changed rows: ' . $this->changedRows . PHP_EOL . |
||
53 | 'Values: ' . print_r($this->values, true) . PHP_EOL; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
54 | } |
||
55 | |||
56 | public function jsonSerialize() |
||
57 | { |
||
58 | return get_object_vars($this); |
||
59 | } |
||
60 | } |