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.

AppVeyorHandler::handle()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
ccs 0
cts 10
cp 0
cc 2
nc 1
nop 1
crap 6
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\Repository;
4
5
use ApiClients\Client\AppVeyor\AsyncClientInterface;
6
use ApiClients\Client\AppVeyor\Resource\ProjectInterface;
7
use ApiClients\Client\Github\CommandBus\Command\Repository\AppVeyorCommand;
8
use React\Promise\Promise;
9
use React\Promise\PromiseInterface;
10
11
final class AppVeyorHandler
12
{
13
    /**
14
     * @var AsyncClientInterface
15
     */
16
    private $appveyor;
17
18
    /**
19
     * @param AsyncClientInterface $appveyor
20
     */
21
    public function __construct(AsyncClientInterface $appveyor)
22
    {
23
        $this->appveyor = $appveyor;
24
    }
25
26
    /**
27
     * @param  AppVeyorCommand  $command
28
     * @return PromiseInterface
29
     */
30
    public function handle(AppVeyorCommand $command): PromiseInterface
31
    {
32
        return new Promise(function ($resolve, $reject) use ($command) {
33
            $repo = false;
34
            $this->appveyor->projects()->filter(function (ProjectInterface $project) use ($command) {
35
                return \strtolower($project->repositoryType()) === 'github' &&
36
                    \strtolower($project->repositoryName()) === \strtolower($command->getRepository());
37
            })->take(1)->subscribe(function ($repository) use (&$repo) {
38
                $repo = $repository;
39
            }, function ($error) use ($reject) {
40
                $reject($error);
41
            }, function () use (&$repo, $resolve) {
42
                $resolve($repo);
43
            });
44
        });
45
    }
46
}
47