Passed
Branch master (a01aa4)
by Mike
03:32
created

AbstractHandler::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 1
crap 2
1
<?php
2
3
namespace MGDigital\BusQue\Handler;
4
5
use MGDigital\BusQue\BusQueCommandInterface;
6
use MGDigital\BusQue\Implementation;
7
8
abstract class AbstractHandler
9
{
10
11
    protected $implementation;
12
13 5
    public function __construct(Implementation $implementation)
14
    {
15 5
        $this->implementation = $implementation;
16 5
    }
17
18 3
    protected function process(BusQueCommandInterface $command): array
19
    {
20 3
        $baseCommand = $command->getCommand();
21 3
        $queueName = $this->implementation->getQueueResolver()
22 3
            ->resolveQueueName($baseCommand);
23 3
        $commandId = $command->getId() ?: $this->implementation->getCommandIdGenerator()
24 3
            ->generateId($baseCommand);
25 3
        $serialized = $this->implementation->getCommandSerializer()
26 3
            ->serialize($baseCommand);
27 3
        return [ $queueName, $commandId, $serialized ];
28
    }
29
}
30