Code Duplication    Length = 19-20 lines in 2 locations

src/Queue/Subscribe/AMQPSubscribeEventQueue.php 1 location

@@ 152-171 (lines=20) @@
149
    /**
150
     * @param string $message
151
     */
152
    private function handle($message)
153
    {
154
        try {
155
            $event = $this->serializer->deserialize($message);
156
        } catch (\Exception $e) { // catch only deserialize exception
157
            // it's a critical error
158
            // it is necessary to react quickly to it
159
            $this->logger->critical('Failed denormalize a event in the AMQP queue', [$message, $e->getMessage()]);
160
161
            // try denormalize in later
162
            $this->declareQueue();
163
            $this->channel->basic_publish(new AMQPMessage($message), '', $this->queue_name);
164
165
            return; // no event for handle
166
        }
167
168
        foreach ($this->handlers as $handler) {
169
            call_user_func($handler, $event);
170
        }
171
    }
172
}
173

src/Queue/Subscribe/PredisSubscribeEventQueue.php 1 location

@@ 124-142 (lines=19) @@
121
    /**
122
     * @param mixed $message
123
     */
124
    private function handle($message)
125
    {
126
        try {
127
            $event = $this->serializer->deserialize($message);
128
        } catch (\Exception $e) { // catch only deserialize exception
129
            // it's a critical error
130
            // it is necessary to react quickly to it
131
            $this->logger->critical('Failed denormalize a event in the Redis queue', [$message, $e->getMessage()]);
132
133
            // try denormalize in later
134
            $this->client->publish($this->queue_name, $message);
135
136
            return; // no event for handle
137
        }
138
139
        foreach ($this->handlers as $handler) {
140
            call_user_func($handler, $event);
141
        }
142
    }
143
}
144