Passed
Pull Request — master (#53)
by kacper
04:13 queued 14s
created

EventSubscribers   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 71.74%

Importance

Changes 0
Metric Value
eloc 24
c 0
b 0
f 0
dl 0
loc 76
ccs 33
cts 46
cp 0.7174
rs 10
wmc 13

13 Methods

Rating   Name   Duplication   Size   Complexity  
A onTableMap() 0 3 1
A onDelete() 0 3 1
A onHeartbeat() 0 3 1
A getSubscribedEvents() 0 14 1
A onQuery() 0 3 1
A onGTID() 0 3 1
A onWrite() 0 3 1
A allEvents() 0 2 1
A onUpdate() 0 3 1
A onRotate() 0 3 1
A onFormatDescription() 0 3 1
A onMariaDbGtid() 0 3 1
A onXID() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace MySQLReplication\Event;
5
6
use MySQLReplication\Definitions\ConstEventsNames;
7
use MySQLReplication\Event\DTO\DeleteRowsDTO;
8
use MySQLReplication\Event\DTO\EventDTO;
9
use MySQLReplication\Event\DTO\FormatDescriptionEventDTO;
10
use MySQLReplication\Event\DTO\GTIDLogDTO;
11
use MySQLReplication\Event\DTO\HeartbeatDTO;
12
use MySQLReplication\Event\DTO\MariaDbGtidLogDTO;
13
use MySQLReplication\Event\DTO\QueryDTO;
14
use MySQLReplication\Event\DTO\RotateDTO;
15
use MySQLReplication\Event\DTO\TableMapDTO;
16
use MySQLReplication\Event\DTO\UpdateRowsDTO;
17
use MySQLReplication\Event\DTO\WriteRowsDTO;
18
use MySQLReplication\Event\DTO\XidDTO;
19
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
20
21
class EventSubscribers implements EventSubscriberInterface
22
{
23 56
    public static function getSubscribedEvents(): array
24
    {
25
        return [
26 56
            ConstEventsNames::TABLE_MAP => 'onTableMap',
27 56
            ConstEventsNames::UPDATE => 'onUpdate',
28 56
            ConstEventsNames::DELETE => 'onDelete',
29 56
            ConstEventsNames::GTID => 'onGTID',
30 56
            ConstEventsNames::QUERY => 'onQuery',
31 56
            ConstEventsNames::ROTATE => 'onRotate',
32 56
            ConstEventsNames::XID => 'onXID',
33 56
            ConstEventsNames::WRITE => 'onWrite',
34 56
            ConstEventsNames::MARIADB_GTID => 'onMariaDbGtid',
35 56
            ConstEventsNames::FORMAT_DESCRIPTION => 'onFormatDescription',
36 56
            ConstEventsNames::HEARTBEAT => 'onHeartbeat',
37
        ];
38
    }
39
40 1
    public function onUpdate(UpdateRowsDTO $event): void
41
    {
42 1
        $this->allEvents($event);
43 1
    }
44
45
    protected function allEvents(EventDTO $event): void
46
    {
47
    }
48
49 51
    public function onTableMap(TableMapDTO $event): void
50
    {
51 51
        $this->allEvents($event);
52 51
    }
53
54 1
    public function onDelete(DeleteRowsDTO $event): void
55
    {
56 1
        $this->allEvents($event);
57 1
    }
58
59
    public function onGTID(GTIDLogDTO $event): void
60
    {
61
        $this->allEvents($event);
62
    }
63
64 56
    public function onQuery(QueryDTO $event): void
65
    {
66 56
        $this->allEvents($event);
67 56
    }
68
69
    public function onRotate(RotateDTO $event): void
70
    {
71
        $this->allEvents($event);
72
    }
73
74 3
    public function onXID(XidDTO $event): void
75
    {
76 3
        $this->allEvents($event);
77 3
    }
78
79 53
    public function onWrite(WriteRowsDTO $event): void
80
    {
81 53
        $this->allEvents($event);
82 53
    }
83
84
    public function onMariaDbGtid(MariaDbGtidLogDTO $event): void
85
    {
86
        $this->allEvents($event);
87
    }
88
89 56
    public function onFormatDescription(FormatDescriptionEventDTO $event): void
90
    {
91 56
        $this->allEvents($event);
92 56
    }
93
94
    public function onHeartbeat(HeartbeatDTO $event): void
95
    {
96
        $this->allEvents($event);
97
    }
98
}