Completed
Push — master ( 674d5a...194be7 )
by Gorka
04:12
created

UsersByIdsAction::__invoke()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 21
nc 1
nop 1
dl 0
loc 31
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\IdentityAccess\Infrastructure\Symfony\HttpAction;
16
17
use Kreta\IdentityAccess\Application\Query\UsersOfIdsQuery;
18
use Kreta\SharedKernel\Application\QueryBus;
19
use Symfony\Component\HttpFoundation\JsonResponse;
20
use Symfony\Component\HttpFoundation\Request;
21
22
class UsersByIdsAction
23
{
24
    private $queryBus;
25
26
    public function __construct(QueryBus $queryBus)
27
    {
28
        $this->queryBus = $queryBus;
29
    }
30
31
    public function __invoke(Request $request) : JsonResponse
32
    {
33
        $ids = explode(',', $request->query->get('ids'));
34
35
        $this->queryBus->handle(
36
            new UsersOfIdsQuery($ids),
37
            $result
38
        );
39
40
        return new JsonResponse($result);
41
42
        return new JsonResponse([
0 ignored issues
show
Unused Code introduced by
return new \Symfony\Comp...images/bespina.jpg'))); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
43
            [
44
                'id'         => '61c0d185-fc68-46f2-9c5f-783dc6096029',
45
                'username'   => 'gorkalaucirica',
46
                'email'      => '[email protected]',
47
                'first_name' => 'Gorka',
48
                'last_name'  => 'Laucirica',
49
                'full_name'  => 'Gorka Laucirica',
50
                'image'      => '/images/gorka.jpg',
51
            ], [
52
                'id'         => 'a38f8ef4-400b-4229-a5ff-712ff5f72b27',
53
                'username'   => 'benatespina',
54
                'email'      => '[email protected]',
55
                'first_name' => 'Beñat',
56
                'last_name'  => 'Espiña',
57
                'full_name'  => 'Beñat Espiña',
58
                'image'      => '/images/bespina.jpg',
59
            ],
60
        ]);
61
    }
62
}
63