Completed
Push — master ( 025fa8...308afa )
by Nicolas
02:00
created

MetaDataEnricherRegistry::subscribe()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 3
eloc 4
nc 4
nop 1
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
    /**
41
     * @return MetadataEnrichingEventStreamDecorator
42
     */
43
    public function getEventStreamDecorator()
44
    {
45
        return $this->eventStreamDecorator;
46
    }
47
}
48