CommandBus   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 3 1
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