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 ( 2a68b7...deb6f2 )
by Cees-Jan
03:03
created

AddLabelHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 14
cp 0
cc 1
eloc 10
nc 1
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\Repository;
4
5
use ApiClients\Client\Github\CommandBus\Command\Repository\AddLabelCommand;
6
use ApiClients\Client\Github\Resource\LabelInterface;
7
use ApiClients\Foundation\Hydrator\Hydrator;
8
use ApiClients\Foundation\Transport\JsonStream;
9
use ApiClients\Foundation\Transport\Service\RequestService;
10
use React\Promise\PromiseInterface;
11
use RingCentral\Psr7\Request;
12
use Rx\Observable;
13
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
14
use function React\Promise\resolve;
15
use function WyriHaximus\React\futureFunctionPromise;
16
17
final class AddLabelHandler
18
{
19
    /**
20
     * @var RequestService
21
     */
22
    private $requestService;
23
24
    /**
25
     * @var Hydrator
26
     */
27
    private $hydrator;
28
29
    /**
30
     * @param RequestService $requestService
31
     * @param Hydrator $hydrator
32
     */
33
    public function __construct(RequestService $requestService, Hydrator $hydrator)
34
    {
35
        $this->requestService = $requestService;
36
        $this->hydrator = $hydrator;
37
    }
38
39
    /**
40
     * @param AddLabelCommand $command
41
     * @return PromiseInterface
42
     */
43
    public function handle(AddLabelCommand $command): PromiseInterface
44
    {
45
        return $this->requestService->handle(
46
            new Request(
47
                'POST',
48
                'repos/' . $command->getRepository() . '/labels',
49
                [],
50
                new JsonStream([
51
                    'name' => $command->getName(),
52
                    'color' => $command->getColour(),
53
                ])
54
            )
55
        )->then(function ($label) {
56
            return $this->hydrator->hydrate(LabelInterface::HYDRATE_CLASS, $label->getBody()->getJson());
57
        });
58
    }
59
}
60