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.

RenameHandler   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 34
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

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