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 ( 0d08ce...5e5f9f )
by Cees-Jan
05:15
created

RepositoriesHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 97.5 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 39
loc 40
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A handle() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler\User;
4
5
use ApiClients\Client\Github\CommandBus\Command\User\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 View Code Duplication
final class RepositoriesHandler
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...
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 1
    public function __construct(IteratePagesService $iteratePagesService, Hydrator $hydrator)
32
    {
33 1
        $this->iteratePagesService = $iteratePagesService;
34 1
        $this->hydrator = $hydrator;
35 1
    }
36
37
    /**
38
     * Fetch the given repository and hydrate it
39
     *
40
     * @param RepositoriesCommand $command
41
     * @return PromiseInterface
42
     */
43 1
    public function handle(RepositoriesCommand $command): PromiseInterface
44
    {
45 1
        return resolve(
46 1
            $this->iteratePagesService->iterate('users/' . $command->getLogin() . '/repos')
47
                ->flatMap(function ($repositories) {
48 1
                    return Observable::fromArray($repositories);
49 1
                })->map(function ($repository) {
50 1
                    return $this->hydrator->hydrate(RepositoryInterface::HYDRATE_CLASS, $repository);
51 1
                })
52
        );
53
    }
54
}
55