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.

EmojisHandler::handle()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
ccs 12
cts 12
cp 1
cc 2
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 function ApiClients\Tools\Rx\observableFromArray;
10
use React\Promise\PromiseInterface;
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 1
                ->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 observableFromArray($structuredEmojis);
54
                })->map(function ($emoji) {
55 1
                    return $this->hydrator->hydrate(EmojiInterface::HYDRATE_CLASS, $emoji);
56 1
                })
57
        );
58
    }
59
}
60