AbstractListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 37
ccs 3
cts 7
cp 0.4286
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getChunkSize() 0 3 1
A sendAck() 0 7 1
A sendNack() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\RabbitMQ\Business\Model\Worker\Listener;
5
6
7
use DataProvider\RabbitMqMessageDataProvider;
8
use PhpAmqpLib\Channel\AMQPChannel;
9
use Xervice\Core\Plugin\AbstractBusinessPlugin;
10
use Xervice\RabbitMQ\Business\Dependency\Worker\Listener\ListenerInterface;
11
12
abstract class AbstractListener extends AbstractBusinessPlugin implements ListenerInterface
13
{
14
    protected const DEFAULT_CHUNKSIZE = 100;
15
16
    /**
17
     * @return int
18
     */
19
    public function getChunkSize() : int
20
    {
21
        return self::DEFAULT_CHUNKSIZE;
22
    }
23
24
    /**
25
     * @param \PhpAmqpLib\Channel\AMQPChannel $channel
26
     * @param \DataProvider\RabbitMqMessageDataProvider $messageDataProvider
27
     */
28 2
    public function sendAck(
29
        AMQPChannel $channel,
30
        RabbitMqMessageDataProvider $messageDataProvider,
31
        bool $multiple = false
32
    ): void
33
    {
34 2
        $channel->basic_ack($messageDataProvider->getDeliveryTag(), $multiple);
35 2
    }
36
37
    /**
38
     * @param \PhpAmqpLib\Channel\AMQPChannel $channel
39
     * @param \DataProvider\RabbitMqMessageDataProvider $messageDataProvider
40
     */
41
    public function sendNack(
42
        AMQPChannel $channel,
43
        RabbitMqMessageDataProvider $messageDataProvider,
44
        bool $multiple = false,
45
        bool $requeue = true
46
    ): void
47
    {
48
        $channel->basic_nack($messageDataProvider->getDeliveryTag(), $multiple, $requeue);
49
    }
50
}