CommandRegistry::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php namespace Nwidart\LaravelBroadway\Registries;
2
3
use Broadway\CommandHandling\CommandBus;
4
5
class CommandRegistry extends BaseRegistry implements Registry
6
{
7
    /**
8
     * @var CommandBus
9
     */
10
    private $commandBus;
11
12
    /**
13
     * @param CommandBus $commandBus
14
     */
15
    public function __construct(CommandBus $commandBus)
16
    {
17
        $this->commandBus = $commandBus;
18
    }
19
20
    /**
21
     * Subscribe the given array of command handlers on the command bus
22
     * @param array $handlers
23
     */
24
    public function subscribe($handlers)
25
    {
26
        $handlers = $this->isTraversable($handlers) ? $handlers : [$handlers];
27
28
        foreach ($handlers as $commandHandler) {
29
            $this->commandBus->subscribe($commandHandler);
30
        }
31
    }
32
}
33