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::extract()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 3.0261
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