Completed
Push — master ( 682c63...7c9f7b )
by Yo
03:31
created

ServiceNameResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
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
    /**
15
     * {@inheritdoc}
16
     */
17 2
    public function resolve(string $methodName) : string
18
    {
19 2
        return array_key_exists($methodName, $this->methodMappingList)
20 1
            ? $this->methodMappingList[$methodName]
21 2
            : $methodName
22
        ;
23
    }
24
25
    /**
26
     * @param string $methodName
27
     * @param string $serviceId
28
     */
29 2
    public function addMethodMapping(string $methodName, string $serviceId)
30
    {
31 2
        $this->methodMappingList[$methodName] = $serviceId;
32 2
    }
33
}
34