Passed
Push — master ( 772c92...f3c67a )
by Evgeniy
01:14 queued 12s
created

ParameterService   A

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
class ParameterService
10
{
11
    /**
12
     * @param ReflectionParameter $parameter
13
     * @param array<string> $annotations
14
     * @return string
15
     */
16 6
    public function getName(ReflectionParameter $parameter, array $annotations): string
17
    {
18 6
        $result = $parameter->getClass() === null ? $parameter->name : $parameter->getClass()->name;
19 6
        if (array_key_exists($result, $annotations)) {
20 3
            $result = $annotations[$result];
21
        }
22 6
        return $result;
23
    }
24
}
25