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:13
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 React\Promise\Promise;
9
use React\Promise\PromiseInterface;
10
11
final class AppVeyorHandler
12
{
13
    /**
14
     * @var AsyncClient
15
     */
16
    private $appveyor;
17
18
    /**
19
     * @param AsyncClient $appveyor
20
     */
21
    public function __construct(AsyncClient $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