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

AbstractHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 11 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