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
Push — master ( 69e8fc...dcfb05 )
by Cees-Jan
13s
created

Factory::createCommandBus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A Factory::createHydrator() 8 8 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation;
4
5
use ApiClients\Foundation\Hydrator\Factory as HydratorFactory;
6
use ApiClients\Foundation\Hydrator\Hydrator;
7
use ApiClients\Foundation\Transport\Client as TransportClient;
8
use ApiClients\Foundation\Transport\Factory as TransportFactory;
9
use ApiClients\Tools\CommandBus\CommandBus;
10
use ApiClients\Tools\CommandBus\Factory as CommandBusFactory;
11
use DI\ContainerBuilder;
12
use Interop\Container\ContainerInterface;
13
use InvalidArgumentException;
14
use League\Event\Emitter;
15
use League\Event\EmitterInterface;
16
use React\EventLoop\LoopInterface;
17
18
final class Factory
19
{
20
    public static function create(
21
        LoopInterface $loop,
22
        array $options = []
23
    ): Client {
24
        return new Client(
25
            self::createContainer($loop, $options)
26
        );
27
    }
28
29
    private static function createContainer(LoopInterface $loop, array $options): ContainerInterface
30
    {
31
        $container = new ContainerBuilder();
32
33
        $container->addDefinitions([
34
            EmitterInterface::class => new Emitter(),
35
            LoopInterface::class => $loop,
36
            TransportClient::class => function (ContainerInterface $container, LoopInterface $loop) use ($options) {
37
                return self::createTransport($container, $loop, $options);
38
            },
39
            Hydrator::class => function (ContainerInterface $container) use ($options) {
40
                return self::createHydrator($container, $options);
41
            },
42
            CommandBus::class => function (ContainerInterface $container) {
43
                return CommandBusFactory::create($container);
44
            },
45
        ]);
46
47
        return $container->build();
48
    }
49
50 View Code Duplication
    private static function createTransport(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
        ContainerInterface $container,
52
        LoopInterface $loop,
53
        array $options = []
54
    ): TransportClient {
55
        if (!isset($options[Options::TRANSPORT_OPTIONS])) {
56
            throw new InvalidArgumentException('Missing Transport options');
57
        }
58
59
        return TransportFactory::create($container, $loop, $options[Options::TRANSPORT_OPTIONS]);
60
    }
61
62 View Code Duplication
    private static function createHydrator(ContainerInterface $container, array $options = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    {
64
        if (!isset($options[Options::HYDRATOR_OPTIONS])) {
65
            throw new InvalidArgumentException('Missing Hydrator options');
66
        }
67
68
        return HydratorFactory::create($container, $options[Options::HYDRATOR_OPTIONS]);
69
    }
70
}
71