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 ( 6776ef...c935c0 )
by Cees-Jan
07:09
created

CollectionHandler::hydrate()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 11

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 20
loc 20
rs 8.8571
cc 5
eloc 11
nc 5
nop 3
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 View Code Duplication
    public function hydrate(AnnotationInterface $annotation, array $json, ResourceInterface $object): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
    {
15
        if (!($annotation instanceof Collection)) {
16
            return $json;
17
        }
18
19
        foreach ($annotation->properties() as $property) {
20
            $array = $json[$property];
21
            $json[$property] = [];
22
            foreach ($array as $resource) {
23
                if ($resource === null) {
24
                    continue;
25
                }
26
27
                $json[$property][] = $this->getHydrator()->hydrate($annotation->get($property), $resource);
28
            }
29
        }
30
31
        return $json;
32
    }
33
34 View Code Duplication
    public function extract(AnnotationInterface $annotation, ResourceInterface $object, array $json): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    {
36
        if (!($annotation instanceof Collection)) {
37
            return $json;
38
        }
39
40
        foreach ($annotation->properties() as $property) {
41
            $array = $json[$property];
42
            $json[$property] = [];
43
            foreach ($array as $resource) {
44
                $json[$property][] = $this->getHydrator()->extract($annotation->get($property), $resource);
45
            }
46
        }
47
48
        return $json;
49
    }
50
}
51