Passed
Pull Request — master (#6)
by Moln
05:27
created

QueryDTO::getExecutionTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
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
16 62
    public function __construct(
17
        EventInfo $eventInfo,
18
        string $database,
19
        int $executionTime,
20
        string $query
21
    ) {
22 62
        parent::__construct($eventInfo);
23
24 62
        $this->executionTime = $executionTime;
25 62
        $this->query = $query;
26 62
        $this->database = $database;
27
    }
28
29
    public function getDatabase(): string
30
    {
31
        return $this->database;
32
    }
33
34
    public function getExecutionTime(): int
35
    {
36
        return $this->executionTime;
37
    }
38
39 5
    public function getQuery(): string
40
    {
41 5
        return $this->query;
42
    }
43
44 62
    public function getType(): string
45
    {
46 62
        return $this->type;
47
    }
48
49
    public function __toString(): string
50
    {
51
        return PHP_EOL .
52
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
53
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
54
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
55
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL .
56
            'Database: ' . $this->database . PHP_EOL .
57
            'Execution time: ' . $this->executionTime . PHP_EOL .
58
            'Query: ' . $this->query . PHP_EOL;
59
    }
60
61
    public function jsonSerialize()
62
    {
63
        return get_object_vars($this);
64
    }
65
}