BusBuildersFromConfig::convert()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace League\Tactician\Bundle\DependencyInjection\Compiler\BusBuilder;
5
6
final class BusBuildersFromConfig
7
{
8
    const DEFAULT_METHOD_INFLECTOR = 'tactician.handler.method_name_inflector.handle';
9
10
    const DEFAULT_BUS_ID = 'default';
11
12 90
    public static function convert(array $config): BusBuilders
13
    {
14 90
        $defaultInflector = $config['method_inflector'] ?? self::DEFAULT_METHOD_INFLECTOR;
15
16 90
        $builders = [];
17 90
        foreach ($config['commandbus'] ?? [] as $busId => $busConfig) {
18 90
            $builders[] = new BusBuilder(
19 90
                $busId,
20 90
                $busConfig['method_inflector'] ?? $defaultInflector,
21 90
                $busConfig['middleware']
22
            );
23
        }
24
25 90
        return new BusBuilders($builders, $config['default_bus'] ?? self::DEFAULT_BUS_ID);
26
    }
27
}
28