HandlersLocatorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\Laminas\Messenger\Factory\Handler;
6
7
use Psr\Container\ContainerInterface;
8
use Symfony\Component\Messenger\Handler\HandlersLocatorInterface;
9
use TMV\Laminas\Messenger\Handler\ContainerHandlersLocator;
10
11
/**
12
 * @psalm-api
13
 */
14
final class HandlersLocatorFactory
15
{
16 4
    /** @var string */
17
    private $busName;
18 4
19 4
    public function __construct(string $busName = 'messenger.bus.default')
20
    {
21 4
        $this->busName = $busName;
22
    }
23
24 4
    public function __invoke(ContainerInterface $container): HandlersLocatorInterface
25
    {
26 4
        /** @var array<string, mixed> $config */
27
        $config = $container->has('config') ? $container->get('config') : [];
28 4
        /** @var string[][]|array<string, array<string|callable>> $handlerDescriptors */
29
        $handlerDescriptors = $config['messenger']['buses'][$this->busName]['handlers'] ?? [];
30
31
        return new ContainerHandlersLocator($container, $handlerDescriptors);
32
    }
33
}
34