Passed
Push — trunk ( 60c287...522604 )
by Christian
21:52 queued 08:22
created

CollectingMessageBus   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessages() 0 3 1
A dispatch() 0 7 1
A clear() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Test\Stub\MessageBus;
4
5
use Symfony\Component\Messenger\Envelope;
6
use Symfony\Component\Messenger\MessageBusInterface;
7
8
/**
9
 * @final
10
 */
11
class CollectingMessageBus implements MessageBusInterface
12
{
13
    /**
14
     * @var array<Envelope>
15
     */
16
    private array $messages = [];
17
18
    public function dispatch(object $message, array $stamps = []): Envelope
19
    {
20
        $envelope = new Envelope($message);
21
22
        $this->messages[] = $envelope;
23
24
        return $envelope;
25
    }
26
27
    /**
28
     * @return array<Envelope>
29
     */
30
    public function getMessages(): array
31
    {
32
        return $this->messages;
33
    }
34
35
    public function clear(): void
36
    {
37
        $this->messages = [];
38
    }
39
}
40