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 ( 1c2332...e42a09 )
by Cees-Jan
11s
created

Factory   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 43
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 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\Hydrator\Annotations;
6
7
class Factory
8
{
9
    const ANNOTATIONS = [
10
        Annotations\Collection::class => Annotations\Handler\CollectionHandler::class,
11
        Annotations\Nested::class => Annotations\Handler\NestedHandler::class,
12
        Annotations\Rename::class => Annotations\Handler\RenameHandler::class,
13
    ];
14
15 6
    public static function create(array $options = []): Hydrator
16
    {
17 6
        $options[Options::ANNOTATIONS] = static::annotations($options[Options::ANNOTATIONS] ?? []);
18
19 6
        $hydrator = new Hydrator($options);
20
21 6
        self::preheat($hydrator, $options);
22
23 6
        return $hydrator;
24
    }
25
26 6
    protected static function annotations(array $annotations): array
27
    {
28 6
        foreach (static::ANNOTATIONS as $annotation => $handler) {
29 6
            if (isset($annotations[$annotation])) {
30
                continue;
31
            }
32
33 6
            $annotations[$annotation] = $handler;
34
        }
35
36 6
        return $annotations;
37
    }
38
39 6
    protected static function preheat(Hydrator $hydrator, array $options)
40
    {
41 6
        $hasNamespaceDir = isset($options[Options::NAMESPACE_DIR]);
42
        $hasNamespace = isset($options[Options::NAMESPACE]);
43 6
        if (!$hasNamespaceDir || !$hasNamespace) {
44 6
            return;
45
        }
46
47
        $hydrator->preheat($options[Options::NAMESPACE_DIR], $options[Options::NAMESPACE]);
48 1
    }
49
}
50