CompositeEventDispatcher::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
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
}