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 ( 9afc59...600839 )
by Cees-Jan
04:36
created

CollectionHandler   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 3
dl 0
loc 45
ccs 18
cts 22
cp 0.8182
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B hydrate() 0 25 6
A extract() 0 16 4
1
<?php
2
declare(strict_types=1);
3
4
namespace ApiClients\Foundation\Hydrator\Annotations\Handler;
5
6
use ApiClients\Foundation\Hydrator\Annotations\Collection;
7
use ApiClients\Foundation\Hydrator\AnnotationInterface;
8
use ApiClients\Foundation\Hydrator\HandlerInterface;
9
use ApiClients\Foundation\Resource\ResourceInterface;
10
11
class CollectionHandler extends AbstractHandler implements HandlerInterface
12
{
13 3
    public function hydrate(AnnotationInterface $annotation, array $json, ResourceInterface $object): array
14
    {
15 3
        if (!($annotation instanceof Collection)) {
16
            return $json;
17
        }
18
19 3
        foreach ($annotation->properties() as $property) {
20 3
            $array = $json[$property];
21
22 3
            if (!is_array($array)) {
23
                continue;
24
            }
25
26 3
            $json[$property] = [];
27 3
            foreach ($array as $resource) {
28 3
                if ($resource === null) {
29
                    continue;
30
                }
31
32 3
                $json[$property][] = $this->getHydrator()->hydrate($annotation->get($property), $resource);
33
            }
34
        }
35
36 3
        return $json;
37
    }
38
39 2
    public function extract(AnnotationInterface $annotation, ResourceInterface $object, array $json): array
40
    {
41 2
        if (!($annotation instanceof Collection)) {
42
            return $json;
43
        }
44
45 2
        foreach ($annotation->properties() as $property) {
46 2
            $array = $json[$property];
47 2
            $json[$property] = [];
48 2
            foreach ($array as $resource) {
49 2
                $json[$property][] = $this->getHydrator()->extract($annotation->get($property), $resource);
50
            }
51
        }
52
53 2
        return $json;
54
    }
55
}
56