CommandBus::__construct()   A
last analyzed

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
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * cqrs-symfony-messenger (https://github.com/phpgears/cqrs-symfony-messenger).
5
 * CQRS implementation with Symfony's Messenger.
6
 *
7
 * @license MIT
8
 * @link https://github.com/phpgears/cqrs-symfony-messenger
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Gears\CQRS\Symfony\Messenger;
15
16
use Gears\CQRS\Command;
17
use Gears\CQRS\CommandBus as CommandBusInterface;
18
use Symfony\Component\Messenger\Envelope;
19
use Symfony\Component\Messenger\MessageBusInterface;
20
21
final class CommandBus implements CommandBusInterface
22
{
23
    /**
24
     * Wrapped message bus.
25
     *
26
     * @var MessageBusInterface
27
     */
28
    private $wrappedMessageBus;
29
30
    /**
31
     * CommandBus constructor.
32
     *
33
     * @param MessageBusInterface $wrappedMessageBus
34
     */
35
    public function __construct(MessageBusInterface $wrappedMessageBus)
36
    {
37
        $this->wrappedMessageBus = $wrappedMessageBus;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function handle(Command $command): void
44
    {
45
        $this->wrappedMessageBus->dispatch(new Envelope($command));
46
    }
47
}
48