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::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 2
crap 1
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