ParameterService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getName() 0 7 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