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/ReadModel/JSONLD/OfferLDProjector.php 1 location

@@ 169-188 (lines=20) @@
166
     * @return string[]
167
     *   An associative array of commands and their handler methods.
168
     */
169
    private function getEventHandlers()
170
    {
171
        $events = [];
172
173
        foreach (get_class_methods($this) as $method) {
174
            $matches = [];
175
176
            if (preg_match('/^apply(.+)$/', $method, $matches)) {
177
                $event = $matches[1];
178
                $classNameMethod = 'get' . $event . 'ClassName';
179
180
                if (method_exists($this, $classNameMethod)) {
181
                    $eventFullClassName = call_user_func(array($this, $classNameMethod));
182
                    $events[$eventFullClassName] = $method;
183
                }
184
            }
185
        }
186
187
        return $events;
188
    }
189
190
    /**
191
     * @return string

src/Offer/OfferCommandHandler.php 1 location

@@ 103-121 (lines=19) @@
100
     * @return string[]
101
     *   An associative array of commands and their handler methods.
102
     */
103
    private function getCommandHandlers()
104
    {
105
        $commands = [];
106
107
        foreach (get_class_methods($this) as $method) {
108
            $matches = [];
109
            if (preg_match('/^handle(.+)$/', $method, $matches)) {
110
                $command = $matches[1];
111
                $classNameMethod = 'get' . $command . 'ClassName';
112
113
                if (method_exists($this, $classNameMethod)) {
114
                    $commandFullClassName = call_user_func(array($this, $classNameMethod));
115
                    $commands[$commandFullClassName] = $method;
116
                }
117
            }
118
        }
119
120
        return $commands;
121
    }
122
123
    /**
124
     * @return string