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
Push — master ( ee1be5...1e72ef )
by Cees-Jan
03:09
created

RepositoriesHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 5
cp 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler;
4
5
use ApiClients\Client\Github\CommandBus\Command\RepositoriesCommand;
6
use ApiClients\Client\Github\Resource\RepositoryInterface;
7
use ApiClients\Client\Github\Service\IteratePagesService;
8
use ApiClients\Foundation\Hydrator\Hydrator;
9
use React\Promise\PromiseInterface;
10
use Rx\Observable;
11
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
12
use function React\Promise\resolve;
13
use function WyriHaximus\React\futureFunctionPromise;
14
15
final class RepositoriesHandler
16
{
17
    /**
18
     * @var IteratePagesService
19
     */
20
    private $iteratePagesService;
21
22
    /**
23
     * @var Hydrator
24
     */
25
    private $hydrator;
26
27
    /**
28
     * @param IteratePagesService $iteratePagesService
29
     * @param Hydrator $hydrator
30
     */
31
    public function __construct(IteratePagesService $iteratePagesService, Hydrator $hydrator)
32
    {
33
        $this->iteratePagesService = $iteratePagesService;
34
        $this->hydrator = $hydrator;
35
    }
36
37
    /**
38
     * Fetch the given repository and hydrate it
39
     *
40
     * @param RepositoriesCommand $command
41
     * @return PromiseInterface
42
     */
43
    public function handle(RepositoriesCommand $command): PromiseInterface
44
    {
45
        return resolve(unwrapObservableFromPromise(
46
            $this->iteratePagesService->handle('users/' . $command->getLogin() . '/repos')
47
        )->flatMap(function ($repositories) {
48
            return Observable::fromArray($repositories);
49
        })->map(function ($repository) {
50
            return $this->hydrator->hydrate(RepositoryInterface::HYDRATE_CLASS, $repository);
51
        }));
52
    }
53
}
54