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

CollectingMessageBus::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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