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 ( 350fc3...9dd22f )
by Cees-Jan
02:32
created

NestedHandler::extract()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.0312

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 7
cts 8
cp 0.875
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 3
crap 4.0312
1
<?php
2
declare(strict_types=1);
3
4
namespace ApiClients\Foundation\Hydrator\Annotation\Handler;
5
6
use ApiClients\Foundation\Hydrator\AnnotationInterface;
7
use ApiClients\Foundation\Hydrator\Annotation\Nested;
8
use ApiClients\Foundation\Hydrator\HandlerInterface;
9
use ApiClients\Foundation\Resource\ResourceInterface;
10
11
class NestedHandler extends AbstractHandler implements HandlerInterface
12
{
13 6
    public function hydrate(AnnotationInterface $annotation, array $json, ResourceInterface $object): array
14
    {
15 6
        if (!($annotation instanceof Nested)) {
16
            return $json;
17
        }
18
19 6
        foreach ($annotation->properties() as $property) {
20 6
            if (!isset($json[$property])) {
21 1
                $json[$property] = null;
22 1
                continue;
23
            }
24
25 5
            if (!is_array($json[$property])) {
26
                continue;
27
            }
28
29 5
            $json[$property] = $this->getHydrator()->hydrate($annotation->get($property), $json[$property]);
30
        }
31
32 6
        return $json;
33
    }
34
35 3
    public function extract(AnnotationInterface $annotation, ResourceInterface $object, array $json): array
36
    {
37 3
        if (!($annotation instanceof Nested)) {
38
            return $json;
39
        }
40
41 3
        foreach ($annotation->properties() as $property) {
42 3
            if (!($json[$property] instanceof ResourceInterface)) {
43 1
                continue;
44
            }
45
46 2
            $json[$property] = $this->getHydrator()->extract($annotation->get($property), $json[$property]);
47
        }
48
49 3
        return $json;
50
    }
51
}
52