Completed
Push — master ( 82aaff...06b207 )
by Kamil
14s
created

RequestPasswordResettingAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 28
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A __invoke() 7 7 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
2
3
declare(strict_types = 1);
4
5
namespace Sylius\ShopApiPlugin\Controller\Customer;
6
7
use FOS\RestBundle\View\View;
8
use FOS\RestBundle\View\ViewHandlerInterface;
9
use League\Tactician\CommandBus;
10
use Sylius\ShopApiPlugin\Command\GenerateResetPasswordToken;
11
use Sylius\ShopApiPlugin\Command\SendResetPasswordToken;
12
use Sylius\ShopApiPlugin\Factory\ValidationErrorViewFactoryInterface;
13
use Sylius\ShopApiPlugin\Request\ResendVerificationTokenRequest;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
use Symfony\Component\Validator\Validator\ValidatorInterface;
17
18 View Code Duplication
final class RequestPasswordResettingAction
19
{
20
    /**
21
     * @var ViewHandlerInterface
22
     */
23
    private $viewHandler;
24
25
    /**
26
     * @var CommandBus
27
     */
28
    private $bus;
29
30
    public function __construct(
31
        ViewHandlerInterface $viewHandler,
32
        CommandBus $bus
33
    ) {
34
        $this->viewHandler = $viewHandler;
35
        $this->bus = $bus;
36
    }
37
38
    public function __invoke(Request $request): Response
39
    {
40
        $this->bus->handle(new GenerateResetPasswordToken($request->request->get('email')));
41
        $this->bus->handle(new SendResetPasswordToken($request->request->get('email')));
42
43
        return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT));
44
    }
45
}
46