CompositeEventDispatcher::dispatchEvent()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
/******************************************************************************
3
 * Copyright (c) 2016 Constantin Galbenu <[email protected]>             *
4
 ******************************************************************************/
5
6
namespace Gica\Cqrs\Event\EventDispatcher;
7
8
9
use Gica\Cqrs\Event\EventDispatcher;
10
use Gica\Cqrs\Event\EventWithMetaData;
11
12
class CompositeEventDispatcher implements EventDispatcher
13
{
14
    /**
15
     * @var EventDispatcher[]
16
     */
17
    private $eventDispatchers;
18
19 1
    public function __construct(
20
        EventDispatcher ...$eventDispatchers
21
    )
22
    {
23 1
        $this->eventDispatchers = $eventDispatchers;
24 1
    }
25
26 1
    public function dispatchEvent(EventWithMetaData $eventWithMetadata)
27
    {
28 1
        foreach ($this->eventDispatchers as $eventDispatcher) {
29 1
            $eventDispatcher->dispatchEvent($eventWithMetadata);
30
        }
31
    }
32
}