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 ( 588993...886570 )
by Cees-Jan
08:02
created

AddRepositoryHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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