Completed
Push — 1.1 ( ed8c11...60d65e )
by David
9s
created

AbstractConsumer::callback()   A

Complexity

Conditions 3
Paths 5

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 5
nop 1
1
<?php
2
3
namespace Mouf\AmqpClient;
4
5
abstract class AbstractConsumer implements ConsumerInterface
6
{
7
    use ConsumerTrait;
8
9
    public function callback($msg)
10
    {
11
        try {
12
            $this->onMessageReceived($msg);
13
14
            $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
15
        } catch (RetryableExceptionInterface $e) {
16
            $msg->delivery_info['channel']->basic_nack($msg->delivery_info['delivery_tag'], true, true);
17
        } catch (\Exception $e) {
18
            $msg->delivery_info['channel']->basic_nack($msg->delivery_info['delivery_tag'], true, false);
19
        }
20
    }
21
22
    abstract public function onMessageReceived($msg);
23
}
24