GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e55eef...aa8510 )
by Cees-Jan
02:37
created

CommandBus::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\CommandBus;
4
5
use League\Tactician\CommandBus as Tactician;
6
use League\Tactician\Handler\CommandHandlerMiddleware;
7
use React\EventLoop\LoopInterface;
8
use React\Promise\CancellablePromiseInterface;
9
use function WyriHaximus\React\futurePromise;
10
use function React\Promise\resolve;
11
12
final class CommandBus
13
{
14
    /**
15
     * @var Tactician
16
     */
17
    private $commandBus;
18
19
    /**
20
     * @var LoopInterface
21
     */
22
    private $loop;
23
24
    /**
25
     * @param LoopInterface $loop
26
     * @param CommandHandlerMiddleware $commandHandlerMiddleware
27
     */
28 1
    public function __construct(LoopInterface $loop, CommandHandlerMiddleware $commandHandlerMiddleware)
29
    {
30 1
        $this->loop = $loop;
31 1
        $this->commandBus = new Tactician([
32 1
            $commandHandlerMiddleware,
33
        ]);
34 1
    }
35
36
    /**
37
     * Executes the given command and optionally returns a value
38
     *
39
     * @param object $command
40
     *
41
     * @return mixed
42
     */
43
    public function handle($command): CancellablePromiseInterface
44
    {
45 1
        return futurePromise($this->loop, $command)->then(function ($command) {
46 1
            return resolve($this->commandBus->handle($command));
47 1
        });
48
    }
49
}
50