Passed
Push — master ( 4a06bc...a3462d )
by Moln
06:01 queued 02:08
created

XidDTO   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 37
ccs 5
cts 15
cp 0.3333
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 3 1
A __construct() 0 7 1
A getType() 0 3 1
A getXid() 0 3 1
A __toString() 0 8 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 XidDTO extends EventDTO
10
{
11
    private $type = ConstEventsNames::XID;
12
    private $xid;
13
14 6
    public function __construct(
15
        EventInfo $eventInfo,
16
        string $xid
17
    ) {
18 6
        parent::__construct($eventInfo);
19
20 6
        $this->xid = $xid;
21
    }
22
23
    public function getXid(): string
24
    {
25
        return $this->xid;
26
    }
27
28
    public function __toString(): string
29
    {
30
        return PHP_EOL .
31
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
32
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
33
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
34
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
35
            'Transaction ID: ' . $this->xid . PHP_EOL;
36
    }
37
38 6
    public function getType(): string
39
    {
40 6
        return $this->type;
41
    }
42
43
    public function jsonSerialize()
44
    {
45
        return get_object_vars($this);
46
    }
47
}