Code Duplication    Length = 39-39 lines in 2 locations

src/MySQLReplication/Event/DTO/FormatDescriptionEventDTO.php 1 location

@@ 11-49 (lines=39) @@
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
    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
}

src/MySQLReplication/Event/DTO/HeartbeatDTO.php 1 location

@@ 11-49 (lines=39) @@
8
 * Class HeartbeatDTO
9
 * @package MySQLReplication\Event\DTO
10
 */
11
class HeartbeatDTO extends EventDTO
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
}