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

ServiceNameResolver::addMethodMapping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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