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.

CommandBus::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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 React\Promise\resolve;
10
use function WyriHaximus\React\futurePromise;
11
12
final class CommandBus implements CommandBusInterface
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 2
    public function __construct(LoopInterface $loop, CommandHandlerMiddleware $commandHandlerMiddleware)
29
    {
30 2
        $this->loop = $loop;
31 2
        $this->commandBus = new Tactician([
32 2
            $commandHandlerMiddleware,
33
        ]);
34 2
    }
35
36
    /**
37
     * Executes the given command and optionally returns a value.
38
     *
39
     * @param object $command
40
     *
41
     * @return CancellablePromiseInterface
42
     */
43 1
    public function handle($command): CancellablePromiseInterface
44
    {
45
        return futurePromise($this->loop, $command)->then(function ($command) {
46 1
            return resolve($this->commandBus->handle($command));
47 1
        });
48
    }
49
}
50