Completed
Pull Request — master (#290)
by
unknown
36:49 queued 34:03
created

RequestPasswordResettingAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

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