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

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 5
cts 6
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3.0416
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