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   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 44
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 15 1
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