FailedMessagesRemoveCommandFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\Messenger\Factory\Command;
6
7
use Psr\Container\ContainerInterface;
8
use Symfony\Component\Messenger\Command\FailedMessagesRemoveCommand;
9
use TMV\Messenger\Exception\InvalidArgumentException;
10
11
class FailedMessagesRemoveCommandFactory
12
{
13 2
    public function __invoke(ContainerInterface $container)
14
    {
15 2
        $config = $container->has('config') ? $container->get('config') : [];
16 2
        $failureTransportName = $config['messenger']['failure_transport'] ?? null;
17
18 2
        if (null === $failureTransportName) {
19 1
            throw new InvalidArgumentException('Invalid failure_transport name');
20
        }
21
22
        /** @var ContainerInterface $receiverLocator */
23 1
        $receiverLocator = $container->get('messenger.receivers_locator');
24
25 1
        return new FailedMessagesRemoveCommand(
26 1
            $failureTransportName,
27 1
            $receiverLocator->get($failureTransportName)
28
        );
29
    }
30
}
31