Completed
Pull Request — master (#1)
by Dmitry
12:22
created

PassToAnotherCommandBusMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 4 1
1
<?php
2
3
namespace hiapi\middlewares;
4
5
use League\Tactician\CommandBus;
6
use League\Tactician\Middleware;
7
8
/**
9
 * Class PassToAnotherCommandBusMiddleware
10
 *
11
 * @author Dmytro Naumenko <[email protected]>
12
 */
13
class PassToAnotherCommandBusMiddleware implements Middleware
14
{
15
    /**
16
     * @var CommandBus
17
     */
18
    private $commandBus;
19
20
    public function __construct(CommandBus $commandBus)
21
    {
22
        $this->commandBus = $commandBus;
23
    }
24
25
    /**
26
     * @param object $command
27
     * @param callable $next
28
     *
29
     * @return mixed
30
     */
31
    public function execute($command, callable $next)
32
    {
33
        return $next($this->commandBus->handle($command));
34
    }
35
}
36