DispatchesCommands::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 4
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Traits;
4
5
/**
6
 * Trait DispatchesCommands
7
 * Use this trait to dispatch the commands for the Laravel Tactician Command Bus.
8
 * @author Jose Fonseca <[email protected]>
9
 * @package Hechoenlaravel\JarvisFoundation\Traits
10
 */
11
trait DispatchesCommands
12
{
13
    /**
14
     * Dispatch the Command
15
     * @param string $command Full namespace class name or bind from the Laravel Service container for the command
16
     * @param string $handler Full namespace class name or bind from the Laravel Service container form the command handler
17
     * @param array $input
18
     * @param array $middleware
19
     * @return mixed
20
     */
21
    public function execute($command, $handler, array $input = [], array $middleware = [])
22
    {
23
        $bus = app('Joselfonseca\LaravelTactician\CommandBusInterface');
24
        $bus->addHandler($command, $handler);
25
        return $bus->dispatch($command, $input, $middleware);
26
    }
27
}
28