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

AutoQueuingMiddleware   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 18
ccs 0
cts 11
cp 0
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 7 3
1
<?php
2
3
namespace MGDigital\BusQue\Tactician;
4
5
use League\Tactician\Middleware;
6
use MGDigital\BusQue\AutoQueue\DeciderInterface;
7
use MGDigital\BusQue\BusQueCommandInterface;
8
use MGDigital\BusQue\QueuedCommand;
9
10
class AutoQueuingMiddleware implements Middleware
11
{
12
13
    private $decider;
14
15
    public function __construct(DeciderInterface $decider)
16
    {
17
        $this->decider = $decider;
18
    }
19
20
    public function execute($command, callable $next)
21
    {
22
        if (!$command instanceof BusQueCommandInterface && $this->decider->shouldBeQueued($command)) {
23
            $command = new QueuedCommand($command);
24
        }
25
        return $next($command);
26
    }
27
}
28