Code Duplication    Length = 28-38 lines in 3 locations

src/Controller/Checkout/ChoosePaymentMethodAction.php 1 location

@@ 14-51 (lines=38) @@
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\HttpFoundation\Response;
13
14
final class ChoosePaymentMethodAction
15
{
16
    /**
17
     * @var ViewHandlerInterface
18
     */
19
    private $viewHandler;
20
21
    /**
22
     * @var CommandBus
23
     */
24
    private $bus;
25
26
    /**
27
     * @param ViewHandlerInterface $viewHandler
28
     * @param CommandBus $bus
29
     */
30
    public function __construct(ViewHandlerInterface $viewHandler, CommandBus $bus)
31
    {
32
        $this->viewHandler = $viewHandler;
33
        $this->bus = $bus;
34
    }
35
36
    /**
37
     * @param Request $request
38
     *
39
     * @return Response
40
     */
41
    public function __invoke(Request $request)
42
    {
43
        $this->bus->handle(new ChoosePaymentMethod(
44
            $request->attributes->get('token'),
45
            $request->attributes->get('paymentId'),
46
            $request->request->get('method')
47
        ));
48
49
        return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT));
50
    }
51
}
52

src/Controller/Checkout/ChooseShippingMethodAction.php 1 location

@@ 14-51 (lines=38) @@
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\HttpFoundation\Response;
13
14
final class ChooseShippingMethodAction
15
{
16
    /**
17
     * @var ViewHandlerInterface
18
     */
19
    private $viewHandler;
20
21
    /**
22
     * @var CommandBus
23
     */
24
    private $bus;
25
26
    /**
27
     * @param ViewHandlerInterface $viewHandler
28
     * @param CommandBus $bus
29
     */
30
    public function __construct(ViewHandlerInterface $viewHandler, CommandBus $bus)
31
    {
32
        $this->viewHandler = $viewHandler;
33
        $this->bus = $bus;
34
    }
35
36
    /**
37
     * @param Request $request
38
     *
39
     * @return Response
40
     */
41
    public function __invoke(Request $request)
42
    {
43
        $this->bus->handle(new ChooseShippingMethod(
44
            $request->attributes->get('token'),
45
            $request->attributes->get('shippingId'),
46
            $request->request->get('method')
47
        ));
48
49
        return $this->viewHandler->handle(View::create(null, Response::HTTP_NO_CONTENT));
50
    }
51
}
52

src/Controller/Customer/RequestPasswordResettingAction.php 1 location

@@ 15-42 (lines=28) @@
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\Response;
14
15
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