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 ( 06b165...ec107c )
by Cees-Jan
03:40
created

Factory   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 95.45%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 3
dl 0
loc 52
ccs 21
cts 22
cp 0.9545
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 19 1
A annotations() 0 12 3
A preheat() 0 10 3
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Foundation\Hydrator;
4
5
use ApiClients\Foundation\Events\CommandLocatorEvent;
6
use ApiClients\Foundation\Hydrator\Annotations;
7
use Interop\Container\ContainerInterface;
8
use League\Event\EmitterInterface;
9
10
class Factory
11
{
12
    const ANNOTATIONS = [
13
        Annotations\Collection::class => Annotations\Handler\CollectionHandler::class,
14
        Annotations\Nested::class => Annotations\Handler\NestedHandler::class,
15
        Annotations\Rename::class => Annotations\Handler\RenameHandler::class,
16
    ];
17
18 8
    public static function create(ContainerInterface $container, array $options = []): Hydrator
19
    {
20 8
        $container->get(EmitterInterface::class)->
21 8
            addListener(CommandLocatorEvent::NAME, function (CommandLocatorEvent $event) {
22 1
                $event->add(
23 1
                    __DIR__ . DIRECTORY_SEPARATOR . 'CommandBus' . DIRECTORY_SEPARATOR,
24 1
                    __NAMESPACE__ . '\CommandBus'
25
                );
26 8
            })
27
        ;
28
29 8
        $options[Options::ANNOTATIONS] = static::annotations($options[Options::ANNOTATIONS] ?? []);
30
31 8
        $hydrator = new Hydrator($container, $options);
32
33 8
        self::preheat($hydrator, $options);
34
35 8
        return $hydrator;
36
    }
37
38 8
    protected static function annotations(array $annotations): array
39
    {
40 8
        foreach (static::ANNOTATIONS as $annotation => $handler) {
41 8
            if (isset($annotations[$annotation])) {
42
                continue;
43
            }
44
45 8
            $annotations[$annotation] = $handler;
46
        }
47
48 8
        return $annotations;
49
    }
50
51 8
    protected static function preheat(Hydrator $hydrator, array $options)
52
    {
53 8
        $hasNamespaceDir = isset($options[Options::NAMESPACE_DIR]);
54
        $hasNamespace = isset($options[Options::NAMESPACE]);
55 8
        if (!$hasNamespaceDir || !$hasNamespace) {
56 8
            return;
57
        }
58
59
        $hydrator->preheat($options[Options::NAMESPACE_DIR], $options[Options::NAMESPACE]);
60 1
    }
61
}
62