Passed
Push — master ( d58b05...f1b29b )
by Mike
02:14
created

QueueListener::handleMessage()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 5.667

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 2
dl 0
loc 13
ccs 2
cts 6
cp 0.3333
crap 5.667
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Xervice\EventRabbitMq\Business\Plugin\Listener;
5
6
7
use DataProvider\RabbitMqMessageCollectionDataProvider;
0 ignored issues
show
Bug introduced by
The type DataProvider\RabbitMqMessageCollectionDataProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use PhpAmqpLib\Channel\AMQPChannel;
9
use Xervice\RabbitMQ\Business\Model\Worker\Listener\AbstractListener;
10
11
/**
12
 * @method \Xervice\EventRabbitMq\Business\EventRabbitMqBusinessFactory getFactory()
13
 */
14
class QueueListener extends AbstractListener
15
{
16 1
    public function handleMessage(
17
        RabbitMqMessageCollectionDataProvider $collectionDataProvider,
18
        AMQPChannel $channel
19
    ): void {
20
21 1
        foreach ($collectionDataProvider->getMessages() as $message) {
22
            $event = $message->getMessage();
23
24
            if ($event->hasName()) {
25
                $this->getFactory()->getEventFacade()->eventToListener($event);
26
            }
27
28
            $this->sendAck($channel, $message);
29
        }
30 1
    }
31
32
    /**
33
     * @return string
34
     */
35 1
    public function getQueueName(): string
36
    {
37 1
        return $this->getFactory()->createEventQueue()->getName();
38
    }
39
40
    /**
41
     * @return int
42
     */
43 1
    public function getChunkSize(): int
44
    {
45 1
        return 1000;
46
    }
47
}