Completed
Push — master ( bfde3c...df2f00 )
by Beñat
01:59
created

SimpleBusEventBus   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A publish() 0 6 2
1
<?php
2
3
/*
4
 * This file is part of the Shared Kernel library.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace LIN3S\SharedKernel\Infrastructure\Application\SimpleBus;
15
16
use LIN3S\SharedKernel\Application\EventBus;
17
use LIN3S\SharedKernel\Domain\Model\DomainEvent;
18
use SimpleBus\Message\Bus\Middleware\MessageBusSupportingMiddleware;
19
20
/**
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
class SimpleBusEventBus implements EventBus
24
{
25
    private $messageBus;
26
27
    public function __construct(MessageBusSupportingMiddleware $messageBus)
28
    {
29
        $this->messageBus = $messageBus;
30
    }
31
32
    public function publish(DomainEvent ...$events) : void
33
    {
34
        foreach ($events as $event) {
35
            $this->messageBus->handle($event);
36
        }
37
    }
38
}
39