Passed
Push — master ( cbefbc...3619f4 )
by Frank
16:49 queued 06:49
created

DecoratingMessageDispatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 10
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatch() 0 4 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing;
6
7
class DecoratingMessageDispatcher implements MessageDispatcher
8
{
9
    public function __construct(private MessageDispatcher $dispatcher, private MessageDecorator $decorator)
10
    {
11
    }
12
13
    public function dispatch(Message ...$messages): void
14
    {
15
        $this->dispatcher->dispatch(
16
            ...array_map(fn (Message $message) => $this->decorator->decorate($message), $messages)
17
        );
18
    }
19
}
20