Completed
Push — master ( c7a062...ac0937 )
by Beñat
12s
created

RemoveMemberFromOrganization::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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\TaskManager\Infrastructure\Symfony\HttpAction;
16
17
use Kreta\SharedKernel\Application\CommandBus;
18
use Kreta\TaskManager\Application\Command\Organization\RemoveOrganizationMemberToOrganizationCommand;
19
use Symfony\Component\HttpFoundation\JsonResponse;
20
use Symfony\Component\HttpFoundation\Request;
21
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
22
23 View Code Duplication
class RemoveMemberFromOrganization
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...
24
{
25
    private $commandBus;
26
27
    private $currentUser;
28
29
    public function __construct(CommandBus $commandBus, TokenStorageInterface $tokenStorage)
30
    {
31
        $this->commandBus = $commandBus;
32
        $this->currentUser = $tokenStorage->getToken()->getUser();
33
    }
34
35
    public function __invoke(Request $request) : JsonResponse
36
    {
37
        $userId = $request->get('userId');
38
        $organizationId = $request->get('organizationId');
39
40
        $this->commandBus->handle(
41
            new RemoveOrganizationMemberToOrganizationCommand($userId, $organizationId, $this->currentUser->getUserName())
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
42
        );
43
44
        return new JsonResponse();
45
    }
46
}
47