MiddlewareDomainEventBus   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A publish() 0 4 1
A pullAndPublish() 0 6 2
1
<?php
2
3
/**
4
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2011, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Component\Middleware\DomainEvent\Bus;
12
13
use GpsLab\Component\Middleware\Chain\MiddlewareChain;
14
use GpsLab\Domain\Event\Aggregator\AggregateEvents;
15
use GpsLab\Domain\Event\Bus\EventBus;
16
use GpsLab\Domain\Event\Event;
17
18
class MiddlewareDomainEventBus implements EventBus
19
{
20
    /**
21
     * @var MiddlewareChain
22
     */
23
    private $chain;
24
25
    /**
26
     * @param MiddlewareChain $chain
27
     */
28 2
    public function __construct(MiddlewareChain $chain)
29
    {
30 2
        $this->chain = $chain;
31 2
    }
32
33
    /**
34
     * @param Event $event
35
     */
36 2
    public function publish(Event $event)
37
    {
38 2
        $this->chain->run($event);
39 2
    }
40
41
    /**
42
     * @param AggregateEvents $aggregator
43
     */
44 1
    public function pullAndPublish(AggregateEvents $aggregator)
45
    {
46 1
        foreach ($aggregator->pullEvents() as $event) {
47 1
            $this->publish($event);
48 1
        }
49 1
    }
50
}
51