XidDTO   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 35.29%

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 37
ccs 6
cts 17
cp 0.3529
rs 10
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 __toString() 0 8 1
A getXid() 0 3 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 3
    public function __construct(
15
        EventInfo $eventInfo,
16
        string $xid
17
    ) {
18 3
        parent::__construct($eventInfo);
19
20 3
        $this->xid = $xid;
21 3
    }
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 3
    public function getType(): string
39
    {
40 3
        return $this->type;
41
    }
42
43
    public function jsonSerialize()
44
    {
45
        return get_object_vars($this);
46
    }
47
}