MapByNamingConvention   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A mapCommandToHandler() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Tactician\Handler\Mapping;
6
7
use League\Tactician\Handler\Mapping\ClassName\ClassNameInflector;
8
use League\Tactician\Handler\Mapping\MethodName\MethodNameInflector;
9
10
/**
11
 * The most common mapping you'll see. Pass a pair of inflectors through and
12
 * automatically map your commands to the similarly named class.
13
 */
14
final class MapByNamingConvention implements CommandToHandlerMapping
15
{
16
    private ClassNameInflector $classNameInflector;
17
18
    private MethodNameInflector $methodNameInflector;
19
20 1
    public function __construct(ClassNameInflector $classNameInflector, MethodNameInflector $methodNameInflector)
21
    {
22 1
        $this->classNameInflector  = $classNameInflector;
23 1
        $this->methodNameInflector = $methodNameInflector;
24 1
    }
25
26 1
    public function mapCommandToHandler(string $commandFQCN): MethodToCall
27
    {
28 1
        return new MethodToCall(
29 1
            $this->classNameInflector->getClassName($commandFQCN),
30 1
            $this->methodNameInflector->getMethodName($commandFQCN)
31
        );
32
    }
33
}
34