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.

ScrutinizerHandler::handle()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
ccs 0
cts 11
cp 0
cc 3
nc 1
nop 1
crap 12
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\Repository;
4
5
use ApiClients\Client\Github\CommandBus\Command\Repository\ScrutinizerCommand;
6
use ApiClients\Client\Scrutinizer\AsyncClientInterface;
7
use ApiClients\Client\Scrutinizer\Github\AsyncClientInterface as ScrutinizerGithubAsyncClientInterface;
8
use Clue\React\Buzz\Message\ResponseException;
9
use React\Promise\PromiseInterface;
10
use function React\Promise\reject;
11
use function React\Promise\resolve;
12
13
final class ScrutinizerHandler
14
{
15
    /**
16
     * @var ScrutinizerGithubAsyncClientInterface
17
     */
18
    private $scrutinizer;
19
20
    /**
21
     * @param AsyncClientInterface $client
22
     */
23
    public function __construct(AsyncClientInterface $client)
24
    {
25
        $this->scrutinizer = $client->github();
26
    }
27
28
    /**
29
     * @param  ScrutinizerCommand $command
30
     * @return PromiseInterface
31
     */
32
    public function handle(ScrutinizerCommand $command): PromiseInterface
33
    {
34
        return $this->scrutinizer->repository(
35
            $command->getLogin(),
36
            $command->getName()
37
        )->then(null, function ($throwable) {
38
            if (!($throwable instanceof ResponseException)) {
39
                return reject($throwable);
40
            }
41
42
            if ($throwable->getCode() !== 404) {
43
                return reject($throwable);
44
            }
45
46
            return resolve(false);
47
        });
48
    }
49
}
50