Total Complexity | 6 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | class ContainerMethodResolver implements JsonRpcMethodResolverInterface |
||
12 | { |
||
13 | /** @var ContainerInterface */ |
||
14 | private $container; |
||
15 | /** @var string[] */ |
||
16 | private $methodMappingList = []; |
||
17 | |||
18 | /** |
||
19 | * @param ContainerInterface $container |
||
20 | */ |
||
21 | 3 | public function __construct(ContainerInterface $container) |
|
24 | 3 | } |
|
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | 3 | public function resolve(string $methodName) : ?JsonRpcMethodInterface |
|
30 | { |
||
31 | 3 | $serviceName = $this->resolveMethodNameToServiceId($methodName); |
|
32 | |||
33 | 3 | return $this->container->has($serviceName) |
|
34 | 2 | ? $this->container->get($serviceName) |
|
35 | 3 | : null |
|
36 | ; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param string $methodName |
||
41 | * @param string $containerServiceId |
||
42 | */ |
||
43 | 1 | public function addJsonRpcMethodMapping(string $methodName, string $containerServiceId) : void |
|
46 | 1 | } |
|
47 | |||
48 | /** |
||
49 | * @param string $methodName |
||
50 | * |
||
51 | * @return string Method's identifier (returns original method name if no mapping defined) |
||
52 | */ |
||
53 | 3 | protected function resolveMethodNameToServiceId(string $methodName) : string |
|
61 |