Code Duplication    Length = 19-20 lines in 3 locations

src/Offer/ReadModel/History/OfferHistoryProjector.php 1 location

@@ 56-75 (lines=20) @@
53
     * @return string[]
54
     *   An associative array of commands and their handler methods.
55
     */
56
    protected function getEventHandlers()
57
    {
58
        $events = [];
59
60
        foreach (get_class_methods($this) as $method) {
61
            $matches = [];
62
63
            if (preg_match('/^apply(.+)$/', $method, $matches)) {
64
                $event = $matches[1];
65
                $classNameMethod = 'get' . $event . 'ClassName';
66
67
                if (method_exists($this, $classNameMethod)) {
68
                    $eventFullClassName = call_user_func(array($this, $classNameMethod));
69
                    $events[$eventFullClassName] = $method;
70
                }
71
            }
72
        }
73
74
        return $events;
75
    }
76
77
    /**
78
     * @return string

src/Offer/OfferCommandHandler.php 1 location

@@ 87-105 (lines=19) @@
84
     * @return string[]
85
     *   An associative array of commands and their handler methods.
86
     */
87
    private function getCommandHandlers()
88
    {
89
        $commands = [];
90
91
        foreach (get_class_methods($this) as $method) {
92
            $matches = [];
93
            if (preg_match('/^handle(.+)$/', $method, $matches)) {
94
                $command = $matches[1];
95
                $classNameMethod = 'get' . $command . 'ClassName';
96
97
                if (method_exists($this, $classNameMethod)) {
98
                    $commandFullClassName = call_user_func(array($this, $classNameMethod));
99
                    $commands[$commandFullClassName] = $method;
100
                }
101
            }
102
        }
103
104
        return $commands;
105
    }
106
107
    /**
108
     * @return string

src/Offer/ReadModel/JSONLD/OfferLDProjector.php 1 location

@@ 145-164 (lines=20) @@
142
     * @return string[]
143
     *   An associative array of commands and their handler methods.
144
     */
145
    private function getEventHandlers()
146
    {
147
        $events = [];
148
149
        foreach (get_class_methods($this) as $method) {
150
            $matches = [];
151
152
            if (preg_match('/^apply(.+)$/', $method, $matches)) {
153
                $event = $matches[1];
154
                $classNameMethod = 'get' . $event . 'ClassName';
155
156
                if (method_exists($this, $classNameMethod)) {
157
                    $eventFullClassName = call_user_func(array($this, $classNameMethod));
158
                    $events[$eventFullClassName] = $method;
159
                }
160
            }
161
        }
162
163
        return $events;
164
    }
165
166
    /**
167
     * @return string