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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 36
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 16 2
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