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
Pull Request — master (#29)
by Cees-Jan
07:38
created

AppVeyorHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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