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

SingleReceiverExecutor::support()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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
}