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 ( 5a937f...dd0aba )
by Cees-Jan
16s queued 10s
created

PullRequestsHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\Repository;
4
5
use ApiClients\Client\Github\CommandBus\Command\Repository\BranchesCommand;
6
use ApiClients\Client\Github\CommandBus\Command\Repository\MilestonesCommand;
7
use ApiClients\Client\Github\CommandBus\Command\Repository\PullRequestsCommand;
8
use ApiClients\Client\Github\Resource\Repository\BranchInterface;
9
use ApiClients\Client\Github\Resource\Repository\MilestoneInterface;
10
use ApiClients\Client\Github\Resource\Repository\PullRequestInterface;
11
use ApiClients\Client\Github\Service\IteratePagesService;
12
use ApiClients\Foundation\Hydrator\Hydrator;
13
use function ApiClients\Tools\Rx\observableFromArray;
14
use React\Promise\PromiseInterface;
15
use function React\Promise\resolve;
16
17 View Code Duplication
final class PullRequestsHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * @var IteratePagesService
21
     */
22
    private $iteratePagesService;
23
24
    /**
25
     * @var Hydrator
26
     */
27
    private $hydrator;
28
29
    /**
30
     * @param IteratePagesService $iteratePagesService
31
     * @param Hydrator            $hydrator
32
     */
33
    public function __construct(IteratePagesService $iteratePagesService, Hydrator $hydrator)
34
    {
35
        $this->iteratePagesService = $iteratePagesService;
36
        $this->hydrator = $hydrator;
37
    }
38
39
    /**
40
     * @param  PullRequestsCommand  $command
41
     * @return PromiseInterface
42
     */
43
    public function handle(PullRequestsCommand $command): PromiseInterface
44
    {
45
        return resolve(
46
            $this->iteratePagesService->iterate('repos/' . $command->getFullName() . '/pulls')
47
                ->flatMap(function ($milestones) {
48
                    return observableFromArray($milestones);
49
                })->map(function ($milestone) {
50
                    return $this->hydrator->hydrate(PullRequestInterface::HYDRATE_CLASS, $milestone);
51
                })
52
        );
53
    }
54
}
55