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 (#12)
by Cees-Jan
08:42 queued 03:07
created

EmojisHandler::handle()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 12
nc 1
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Github\CommandBus\Handler;
4
5
use ApiClients\Client\Github\CommandBus\Command\EmojisCommand;
6
use ApiClients\Client\Github\Resource\EmojiInterface;
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 React\Promise\resolve;
12
13
final class EmojisHandler
14
{
15
    /**
16
     * @var IteratePagesService
17
     */
18
    private $service;
19
20
    /**
21
     * @var Hydrator
22
     */
23
    private $hydrator;
24
25
    /**
26
     * @param IteratePagesService $service
27
     * @param Hydrator $hydrator
28
     */
29 1
    public function __construct(IteratePagesService $service, Hydrator $hydrator)
30
    {
31 1
        $this->service = $service;
32 1
        $this->hydrator = $hydrator;
33 1
    }
34
35
    /**
36
     * @param EmojisCommand $command
37
     * @return PromiseInterface
38
     */
39 1
    public function handle(EmojisCommand $command): PromiseInterface
0 ignored issues
show
Unused Code introduced by
The parameter $command is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41 1
        return resolve(
42 1
            $this->service->iterate('emojis')
43
                ->flatMap(function ($emojis) {
44 1
                    $structuredEmojis = [];
45
46 1
                    foreach ($emojis as $name => $image) {
47 1
                        $structuredEmojis[] = [
48 1
                            'name' => $name,
49 1
                            'image' => $image,
50
                        ];
51
                    }
52
53 1
                    return Observable::fromArray($structuredEmojis);
54 1
                })->map(function ($emoji) {
55 1
                    return $this->hydrator->hydrate(EmojiInterface::HYDRATE_CLASS, $emoji);
56 1
                })
57
        );
58
    }
59
}
60