Passed
Pull Request — master (#6)
by Moln
03:44
created

TableMapDTO::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
use MySQLReplication\Event\RowEvent\TableMap;
9
10
class TableMapDTO extends EventDTO
11
{
12
    private $type = ConstEventsNames::TABLE_MAP;
13
    private $tableMap;
14
15 58
    public function __construct(
16
        EventInfo $eventInfo,
17
        TableMap $tableMap
18
    ) {
19 58
        parent::__construct($eventInfo);
20
21 58
        $this->tableMap = $tableMap;
22
    }
23
24
    public function __toString(): string
25
    {
26
        return PHP_EOL .
27
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
28
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
29
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
30
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
31
            'Table: ' . $this->tableMap->getTable() . PHP_EOL .
32
            'Database: ' . $this->tableMap->getDatabase() . PHP_EOL .
33
            'Table Id: ' . $this->tableMap->getTableId() . PHP_EOL .
34
            'Columns amount: ' . $this->tableMap->getColumnsAmount() . PHP_EOL;
35
    }
36
37 55
    public function getType(): string
38
    {
39 55
        return $this->type;
40
    }
41
42
    public function jsonSerialize()
43
    {
44
        return get_object_vars($this);
45
    }
46
47
    public function getTableMap(): TableMap
48
    {
49
        return $this->tableMap;
50
    }
51
}