HEX
Server: Apache
System: Linux srv13.cpanelhost.cl 3.10.0-962.3.2.lve1.5.38.el7.x86_64 #1 SMP Thu Jun 18 05:28:41 EDT 2020 x86_64
User: cca63905 (4205)
PHP: 7.3.20
Disabled: NONE
Upload Files
File: //proc/self/root/proc/self/cwd/nueva/vendor/league/tactician/src/Setup/QuickStart.php
<?php

namespace League\Tactician\Setup;

use League\Tactician\CommandBus;
use League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor;
use League\Tactician\Handler\Locator\InMemoryLocator;
use League\Tactician\Handler\MethodNameInflector\HandleInflector;
use League\Tactician\Handler\CommandHandlerMiddleware;
use League\Tactician\Plugins\LockingMiddleware;

/**
 * Builds a working command bus with minimum fuss.
 *
 * Currently, the default setup is:
 * - Handlers instances in memory
 * - The expected handler method is always "handle"
 * - And only one command at a time can be executed.
 *
 * This factory is a decent place to start trying out Tactician but you're
 * better off moving to a custom setup or a framework bundle/module/provider in
 * the long run. As you can see, it's not difficult. :)
 */
class QuickStart
{
    /**
     * Creates a default CommandBus that you can get started with.
     *
     * @param array $commandToHandlerMap
     *
     * @return CommandBus
     */
    public static function create($commandToHandlerMap)
    {
        $handlerMiddleware = new CommandHandlerMiddleware(
            new ClassNameExtractor(),
            new InMemoryLocator($commandToHandlerMap),
            new HandleInflector()
        );

        $lockingMiddleware = new LockingMiddleware();

        return new CommandBus([$lockingMiddleware, $handlerMiddleware]);
    }
}