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

MetaDataEnricherRegistry   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A subscribe() 0 8 3
A getEventStreamDecorator() 0 4 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