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

AbstractHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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