Test Setup Failed
Pull Request — master (#81)
by Valery
09:57
created

PasswordController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A update() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\User\Ajax;
6
7
use App\Controller\AjaxController;
8
use App\Service\User\PasswordService;
9
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\Routing\Annotation\Route;
13
use Throwable;
14
15
final class PasswordController extends AbstractController implements AjaxController
16
{
17
    /**
18
     * @Route("/user/password", methods={"POST"}, name="user_password")
19
     */
20
    public function update(Request $request, PasswordService $service): JsonResponse
21
    {
22
        try {
23
            $service->update($request);
24
25
            return new JsonResponse([]);
26
        } catch (Throwable $e) {
27
            return new JsonResponse([
28
                'message' => $e->getMessage(),
29
            ], 422);
30
        }
31
    }
32
}
33