Completed
Pull Request — master (#2)
by Yo
02:01
created

ServiceNameResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 6
cts 6
cp 1
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
    /**
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