Passed
Branch master (e090ea)
by kacper
04:22
created

HeartbeatDTO::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 8
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 2
1
<?php
2
3
namespace MySQLReplication\Event\DTO;
4
5
use MySQLReplication\Definitions\ConstEventsNames;
6
7
/**
8
 * Class HeartbeatDTO
9
 * @package MySQLReplication\Event\DTO
10
 */
11 View Code Duplication
class HeartbeatDTO extends EventDTO
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $type = ConstEventsNames::HEARTBEAT;
17
18
    /**
19
     * @return string
20
     */
21
    public function getType()
22
    {
23
        return $this->type;
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function __toString()
30
    {
31
        return PHP_EOL .
32
            '=== Event ' . $this->getType() . ' === ' . PHP_EOL .
33
            'Date: ' . $this->eventInfo->getDateTime() . PHP_EOL .
34
            'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
35
            'Event size: ' . $this->eventInfo->getSize() . PHP_EOL;
36
    }
37
38
    /**
39
     * Specify data which should be serialized to JSON
40
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
41
     * @return mixed data which can be serialized by <b>json_encode</b>,
42
     * which is a value of any type other than a resource.
43
     * @since 5.4.0
44
     */
45
    public function jsonSerialize()
46
    {
47
        return get_object_vars($this);
48
    }
49
}