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 ( 3ef44b...b60557 )
by Cees-Jan
14s
created

ReplaceTopicsHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\Repository;
4
5
use ApiClients\Client\Github\CommandBus\Command\Repository\ReplaceTopicsCommand;
6
use ApiClients\Foundation\Transport\Service\RequestService;
7
use ApiClients\Middleware\Json\JsonStream;
8
use React\Promise\PromiseInterface;
9
use RingCentral\Psr7\Request;
10
11 View Code Duplication
final class ReplaceTopicsHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @var RequestService
15
     */
16
    private $requestService;
17
18
    /**
19
     * @param RequestService $requestService
20
     */
21 1
    public function __construct(RequestService $requestService)
22
    {
23 1
        $this->requestService = $requestService;
24 1
    }
25
26
    /**
27
     * @param  ReplaceTopicsCommand $command
28
     * @return PromiseInterface
29
     */
30 1
    public function handle(ReplaceTopicsCommand $command): PromiseInterface
31
    {
32 1
        return $this->requestService->request(
33 1
            new Request(
34 1
                'PUT',
35 1
                'repos/' . $command->getRepository() . '/topics',
36 1
                [],
37 1
                new JsonStream([
38 1
                    'names' => $command->getTopics(),
39
                ])
40
            )
41 1
        )->then(function ($response) {
42 1
            return $response->getBody()->getJson()['names'];
43 1
        });
44
    }
45
}
46