Test Failed
Push — master ( 4ea690...95f852 )
by kacper
14:59 queued 09:58
created

QueryDTO::getQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 3
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
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
}