MetaDataEnricherRegistry   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

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
     * @return MetadataEnrichingEventStreamDecorator
41
     */
42
    public function getEventStreamDecorator()
43
    {
44
        return $this->eventStreamDecorator;
45
    }
46
}
47