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

AutoQueuingMiddleware::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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