MapByNamingConvention::mapCommandToHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
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