Passed
Pull Request — master (#8)
by Moln
05:05
created

EventSubscribers   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Test Coverage

Coverage 78.95%

Importance

Changes 0
Metric Value
eloc 24
c 0
b 0
f 0
dl 0
loc 76
ccs 30
cts 38
cp 0.7895
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 onQuery() 0 3 1
A onGTID() 0 3 1
A onWrite() 0 3 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
A getSubscribedEvents() 0 14 1
A allEvents() 0 2 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 58
    public static function getSubscribedEvents(): array
24
    {
25 58
        return [
26 58
            ConstEventsNames::TABLE_MAP => 'onTableMap',
27 58
            ConstEventsNames::UPDATE => 'onUpdate',
28 58
            ConstEventsNames::DELETE => 'onDelete',
29 58
            ConstEventsNames::GTID => 'onGTID',
30 58
            ConstEventsNames::QUERY => 'onQuery',
31 58
            ConstEventsNames::ROTATE => 'onRotate',
32 58
            ConstEventsNames::XID => 'onXID',
33 58
            ConstEventsNames::WRITE => 'onWrite',
34 58
            ConstEventsNames::MARIADB_GTID => 'onMariaDbGtid',
35 58
            ConstEventsNames::FORMAT_DESCRIPTION => 'onFormatDescription',
36 58
            ConstEventsNames::HEARTBEAT => 'onHeartbeat',
37 58
        ];
38
    }
39
40 1
    public function onUpdate(UpdateRowsDTO $event): void
41
    {
42 1
        $this->allEvents($event);
43
    }
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
    }
53
54 1
    public function onDelete(DeleteRowsDTO $event): void
55
    {
56 1
        $this->allEvents($event);
57
    }
58
59
    public function onGTID(GTIDLogDTO $event): void
60
    {
61
        $this->allEvents($event);
62
    }
63
64 58
    public function onQuery(QueryDTO $event): void
65
    {
66 58
        $this->allEvents($event);
67
    }
68
69 1
    public function onRotate(RotateDTO $event): void
70
    {
71 1
        $this->allEvents($event);
72
    }
73
74 3
    public function onXID(XidDTO $event): void
75
    {
76 3
        $this->allEvents($event);
77
    }
78
79 53
    public function onWrite(WriteRowsDTO $event): void
80
    {
81 53
        $this->allEvents($event);
82
    }
83
84
    public function onMariaDbGtid(MariaDbGtidLogDTO $event): void
85
    {
86
        $this->allEvents($event);
87
    }
88
89 58
    public function onFormatDescription(FormatDescriptionEventDTO $event): void
90
    {
91 58
        $this->allEvents($event);
92
    }
93
94
    public function onHeartbeat(HeartbeatDTO $event): void
95
    {
96
        $this->allEvents($event);
97
    }
98
}
99