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 ( 7250ad...9b5a64 )
by Cees-Jan
14s
created

FileDeleteHandler::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 14
cts 14
cp 1
rs 9.2
c 0
b 0
f 0
cc 2
eloc 13
nc 2
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\Repository\Contents;
4
5
use ApiClients\Client\Github\CommandBus\Command\Repository\Contents\FileDeleteCommand;
6
use ApiClients\Client\Github\Resource\Contents\FileOperationInterface;
7
use ApiClients\Foundation\Hydrator\Hydrator;
8
use ApiClients\Foundation\Transport\Service\RequestService;
9
use ApiClients\Middleware\Json\JsonStream;
10
use React\EventLoop\LoopInterface;
11
use React\Promise\PromiseInterface;
12
use RingCentral\Psr7\Request;
13
14
final class FileDeleteHandler
15
{
16
    /**
17
     * @var RequestService
18
     */
19
    private $requestService;
20
21
    /**
22
     * @var Hydrator
23
     */
24
    private $hydrator;
25
26
    /**
27
     * @var LoopInterface
28
     */
29
    private $loop;
30
31
    /**
32
     * @param RequestService $requestService
33
     * @param Hydrator       $hydrator
34
     * @param LoopInterface  $loop
35
     */
36 3
    public function __construct(RequestService $requestService, Hydrator $hydrator, LoopInterface $loop)
37
    {
38 3
        $this->requestService = $requestService;
39 3
        $this->hydrator = $hydrator;
40 3
        $this->loop = $loop;
41 3
    }
42
43
    /**
44
     * @param  FileDeleteCommand $command
45
     * @return PromiseInterface
46
     */
47 3
    public function handle(FileDeleteCommand $command): PromiseInterface
48
    {
49
        $json = [
50 3
            'message' => $command->getCommitMessage(),
51 3
            'sha' => $command->getSha(),
52
        ];
53
54 3
        if ($command->getBranch() !== '') {
55 1
            $json['branch'] = $command->getBranch();
56
        }
57
58 3
        return $this->requestService->request(
59 3
            new Request(
60 3
                'DELETE',
61 3
                $command->getUrl(),
62 3
                [],
63 3
                new JsonStream($json)
64
            )
65 3
        )->then(function ($operation) {
66 3
            return $this->hydrator->hydrate(FileOperationInterface::HYDRATE_CLASS, $operation->getBody()->getJson());
67 3
        });
68
    }
69
}
70