Failed Conditions
Pull Request — master (#2)
by Yo
02:05
created

ServiceNameResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 5 2
A addMethodMapping() 0 3 1
1
<?php
2
namespace Yoanm\SymfonyJsonRpcHttpServer\Infra\Resolver;
3
4
use Yoanm\JsonRpcServerPsr11Resolver\Domain\Model\ServiceNameResolverInterface;
5
6
/**
7
 * Class ServiceNameResolver
8
 */
9
class ServiceNameResolver implements ServiceNameResolverInterface
10
{
11
    /** @var string[] */
12
    private $methodMappingList = [];
13
14
    public function resolve(string $methodName) : string
15
    {
16
        return array_key_exists($methodName, $this->methodMappingList)
0 ignored issues
show
Bug Best Practice introduced by
The expression return array_key_exists(...ist[$methodName] : null could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
17
            ? $this->methodMappingList[$methodName]
18
            : null
19
        ;
20
    }
21
22
    public function addMethodMapping(string $methodName, string $serviceId)
23
    {
24
        $this->methodMappingList[$methodName] = $serviceId;
25
    }
26
}
27