Test Failed
Push — master ( 1a6b60...537cfd )
by Mike
03:18
created

QueueListener   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 8
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getChunkSize() 0 3 1
A getQueueName() 0 3 1
A handleMessage() 0 13 3
1
<?php
2
3
4
namespace Xervice\EventRabbitMq\Communication\Plugin\Listener;
5
6
7
use DataProvider\EventDataProvider;
8
use DataProvider\RabbitMqMessageCollectionDataProvider;
9
use PhpAmqpLib\Channel\AMQPChannel;
10
use Xervice\RabbitMQ\Worker\Listener\AbstractListener;
0 ignored issues
show
Bug introduced by
The type Xervice\RabbitMQ\Worker\Listener\AbstractListener 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...
11
12
/**
13
 * @method \Xervice\EventRabbitMq\EventRabbitMqFactory getFactory()
14
 */
15
class QueueListener extends AbstractListener
16
{
17
    public function handleMessage(
18
        RabbitMqMessageCollectionDataProvider $collectionDataProvider,
19
        AMQPChannel $channel
20
    ): void {
21
22
        foreach ($collectionDataProvider->getMessages() as $message) {
23
            $event = $message->getMessage();
24
25
            if ($event->hasName()) {
0 ignored issues
show
Bug introduced by
The method hasName() does not exist on Xervice\DataProvider\Bus...r\DataProviderInterface. It seems like you code against a sub-type of Xervice\DataProvider\Bus...r\DataProviderInterface such as DataProvider\EventDataProvider or DataProvider\RabbitMqExchangeDataProvider or DataProvider\RabbitMqQueueDataProvider or DataProvider\EventDataProvider or DataProvider\RabbitMqExchangeDataProvider or DataProvider\RabbitMqQueueDataProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            if ($event->/** @scrutinizer ignore-call */ hasName()) {
Loading history...
26
                $this->getFactory()->getEventFacade()->eventToListener($event);
27
            }
28
29
            $this->sendAck($channel, $message);
30
        }
31
    }
32
33
    /**
34
     * @return string
35
     * @throws \Core\Locator\Dynamic\ServiceNotParseable
36
     */
37
    public function getQueueName(): string
38
    {
39
        return $this->getFactory()->createEventQueue()->getName();
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function getChunkSize(): int
46
    {
47
        return 1000;
48
    }
49
}