GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#3)
by Cees-Jan
02:19
created

Factory::gatherMapping()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 28
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4.0092

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 28
ccs 11
cts 12
cp 0.9167
rs 8.5806
cc 4
eloc 14
nc 4
nop 0
crap 4.0092
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\CommandBus;
4
5
use Composed\Package;
6
use function Composed\packages;
7
use function igorw\get_in;
8
use Interop\Container\ContainerInterface;
9
use League\Tactician\Container\ContainerLocator;
10
use League\Tactician\Handler\CommandHandlerMiddleware;
11
use League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor;
12
use League\Tactician\Handler\MethodNameInflector\HandleInflector;
13
use React\EventLoop\LoopInterface;
14
use WyriHaximus\Tactician\CommandHandler\Mapper;
15
16
final class Factory
17
{
18 1
    public static function create(ContainerInterface $container)
19
    {
20 1
        $commandToHandlerMap = self::gatherMapping();
21
22 1
        $containerLocator = new ContainerLocator(
23
            $container,
24
            $commandToHandlerMap
25
        );
26
27 1
        $commandHandlerMiddleware = new CommandHandlerMiddleware(
28 1
            new ClassNameExtractor(),
29
            $containerLocator,
30 1
            new HandleInflector()
31
        );
32
33 1
        return new CommandBus(
34 1
            $container->get(LoopInterface::class),
35
            $commandHandlerMiddleware
36
        );
37
    }
38
39 1
    private static function gatherMapping()
40
    {
41 1
        $map = [];
42
        /** @var Package $package */
43 1
        foreach (packages() as $package) {
44 1
            $config = $package->getConfig('extra');
45
46 1
            if ($config === null) {
47 1
                continue;
48
            }
49
50 1
            $mapping = get_in(
51
                $config,
52
                [
53 1
                    'api-clients',
54
                    'command-bus'
55
                ]
56
            );
57
58 1
            if ($mapping === null) {
59 1
                continue;
60
            }
61
62
            $map += Mapper::map($package->getPath($mapping['path']), $mapping['namespace']);
63
        }
64
65 1
        return $map;
66
    }
67
}
68