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

ServiceNameResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
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