ParameterService::getName()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
nc 4
nop 2
dl 0
loc 7
rs 10
c 1
b 0
f 0
ccs 3
cts 3
cp 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cekta\DI\Reflection;
6
7
use ReflectionParameter;
8
9
/**
10
 * @internal
11
 */
12
class ParameterService
13
{
14
    /**
15
     * @param ReflectionParameter $parameter
16 6
     * @param array<string> $annotations
17
     * @return string
18 6
     */
19 6
    public function getName(ReflectionParameter $parameter, array $annotations): string
20 3
    {
21
        $result = $parameter->getClass() === null ? $parameter->name : $parameter->getClass()->name;
22 6
        if (array_key_exists($result, $annotations)) {
23
            $result = $annotations[$result];
24
        }
25
        return $result;
26
    }
27
}
28