getEventStreamDecorator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace Nwidart\LaravelBroadway\Registries;
2
3
use Broadway\EventSourcing\MetadataEnrichment\MetadataEnrichingEventStreamDecorator;
4
5
/**
6
 * Class MetaDataEnricherRegistry
7
 *
8
 * @package Nwidart\LaravelBroadway\Registries
9
 * @author Stefano Kowalke <[email protected]>
10
 */
11
class MetaDataEnricherRegistry extends BaseRegistry implements Registry
12
{
13
    /**
14
     * @var MetadataEnrichingEventStreamDecorator $eventStreamDecorator
15
     */
16
    private $eventStreamDecorator;
17
18
    /**
19
     * @param MetadataEnrichingEventStreamDecorator $eventStreamDecorator
20
     */
21
    public function __construct(MetadataEnrichingEventStreamDecorator $eventStreamDecorator)
22
    {
23
        $this->eventStreamDecorator = $eventStreamDecorator;
24
    }
25
26
    /**
27
     * Subscribe the given array of command handlers on the command bus
28
     * @param array $enrichers
29
     */
30
    public function subscribe($enrichers)
31
    {
32
        $enrichers = $this->isTraversable($enrichers) ? $enrichers : [$enrichers];
33
34
        foreach ($enrichers as $enricher) {
35
            $this->eventStreamDecorator->registerEnricher($enricher);
36
        }
37
    }
38
39
    /**
40
     * @return MetadataEnrichingEventStreamDecorator
41
     */
42
    public function getEventStreamDecorator()
43
    {
44
        return $this->eventStreamDecorator;
45
    }
46
}
47