Completed
Branch master (80ac3a)
by kacper
04:34 queued 51s
created

FormatDescriptionEventDTO::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace MySQLReplication\Event\DTO;
4
5
use MySQLReplication\Definitions\ConstEventsNames;
6
7
/**
8
 * Class FormatDescriptionEventDTO
9
 * @package MySQLReplication\Event\DTO
10
 */
11
class FormatDescriptionEventDTO extends EventDTO
12
{
13
    /**
14
     * @var string
15
     */
16
    private $type = ConstEventsNames::FORMAT_DESCRIPTION;
17
18
    /**
19
     * @return string
20
     */
21 54
    public function getType()
22
    {
23 54
        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
}