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

RequestPasswordResettingAction::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
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