Passed
Push — master ( a6a24c...80ac3a )
by kacper
03:22
created

FormatDescriptionEventDTO   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 20%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 2
cts 10
cp 0.2
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 3 1
A __toString() 0 7 1
A getType() 0 3 1
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
}