Test Failed
Pull Request — master (#39)
by Aleksandr
05:36
created

SingleReceiverExecutor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 3
A support() 0 3 1
1
<?php
2
3
namespace OldSound\RabbitMqBundle\ReceiverExecutor;
4
5
use OldSound\RabbitMqBundle\Declarations\ConsumeOptions;
6
use OldSound\RabbitMqBundle\Receiver\ReceiverInterface;
7
8
class SingleReceiverExecutor implements ReceiverExecutorInterface
9
{
10
    /**
11
     * @param ReceiverInterface $receiver
12
     */
13
    public function execute($messages, $receiver): array
14
    {
15
        if (!$this->support($receiver)) {
16
            throw new \InvalidArgumentException('todo');
17
        }
18
        if (count($messages) !== 1) {
19
            throw new \InvalidArgumentException('todo');
20
        }
21
22
        return [$receiver->execute($messages[0])];
23
    }
24
25
    public function support($receiver): bool
26
    {
27
        return $receiver instanceof ReceiverInterface;
28
    }
29
}