Passed
Push — master ( 08dd0c...2460e1 )
by Koldo
02:21
created

ReleaseEventsMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 1
A __construct() 0 3 1
1
<?php
2
3
namespace InFw\TacticianAdapter\CommandBus;
4
5
use InFw\EventSourcing\EmitterInterface;
6
use League\Tactician\Middleware;
7
8
class ReleaseEventsMiddleware implements Middleware
9
{
10
    /**
11
     * @param EmitterInterface $emitter
12
     */
13
    protected $emitter;
14
15
    /**
16
     * @param EmitterInterface $emitter
17
     */
18
    public function __construct(EmitterInterface $emitter)
19
    {
20
        $this->emitter = $emitter;
21
    }
22
23
    /**
24
     * @param object $command
25
     * @param callable $next
26
     *
27
     * @return mixed
28
     */
29
    public function execute($command, callable $next)
30
    {
31
        $returnValue = $next($command);
32
33
        $this->emitter->publish();
34
35
        return $returnValue;
36
    }
37
}
38