Completed
Push — master ( e6daa6...fa6903 )
by Márk
05:04 queued 03:08
created

QueueAllMiddleware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 8 3
1
<?php
2
3
namespace League\Tactician\Bernard;
4
5
use Bernard\Message;
6
use League\Tactician\Middleware;
7
8
/**
9
 * Makes all commands queueable (except the ones that already come from a queue to prevent loops).
10
 *
11
 * Should be placed before {@link League\Tactician\Bernard\QueueMiddleware} in the middleware chain.
12
 */
13
class QueueAllMiddleware implements Middleware
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 3
    public function execute($command, callable $next)
19
    {
20 3
        if (!$command instanceof Message && !$command instanceof QueuedCommand) {
21 1
            $command = new QueueCommand($command);
22 1
        }
23
24 3
        return $next($command);
25
    }
26
}
27