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

PassToAnotherCommandBusMiddleware::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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