QueryDTO   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 42.31%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 25
dl 0
loc 63
ccs 11
cts 26
cp 0.4231
rs 10
c 3
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getThreadId() 0 3 1
A getDatabase() 0 3 1
A getExecutionTime() 0 3 1
A getType() 0 3 1
A jsonSerialize() 0 3 1
A getQuery() 0 3 1
A __toString() 0 10 1
A __construct() 0 13 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 QueryDTO extends EventDTO
10
{
11
    private $executionTime;
12
    private $query;
13
    private $database;
14
    private $type = ConstEventsNames::QUERY;
15
    private $threadId;
16 58
17
    public function __construct(
18
        EventInfo $eventInfo,
19
        string $database,
20
        int $executionTime,
21
        string $query,
22 58
        int $threadId
23
    ) {
24 58
        parent::__construct($eventInfo);
25 58
26 58
        $this->executionTime = $executionTime;
27 58
        $this->query = $query;
28
        $this->database = $database;
29
        $this->threadId = $threadId;
30
    }
31
32
    public function getDatabase(): string
33
    {
34
        return $this->database;
35
    }
36
37
    public function getExecutionTime(): int
38
    {
39 5
        return $this->executionTime;
40
    }
41 5
42
    public function getQuery(): string
43
    {
44 58
        return $this->query;
45
    }
46 58
47
    public function getType(): string
48
    {
49
        return $this->type;
50
    }
51
52
    public function getThreadId(): int
53
    {
54
        return $this->threadId;
55
    }
56
57
    public function __toString(): string
58
    {
59
        return PHP_EOL .
60
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
61
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
62
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
63
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
64
            'Database: ' . $this->database . PHP_EOL .
65 1
            'Execution time: ' . $this->executionTime . PHP_EOL .
66
            'Query: ' . $this->query . PHP_EOL;
67
    }
68
69
    public function jsonSerialize()
70
    {
71
        return get_object_vars($this);
72
    }
73
}