PatchAction   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 18
ccs 2
cts 2
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A patchAction() 0 11 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Rest/Traits/Actions/User/PatchAction.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Rest\Traits\Actions\User;
10
11
use App\DTO\RestDtoInterface;
12
use App\Enum\Role;
13
use App\Rest\Traits\Methods\PatchMethod;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
use Symfony\Component\Routing\Annotation\Route;
17
use Symfony\Component\Routing\Requirement\Requirement;
18
use Symfony\Component\Security\Http\Attribute\IsGranted;
19
use Throwable;
20
21
/**
22
 * Trait PatchAction
23
 *
24
 * Trait to add 'patchAction' for REST controllers for 'ROLE_USER' users.
25
 *
26
 * @see \App\Rest\Traits\Methods\PatchMethod for detailed documents.
27
 *
28
 * @package App\Rest\Traits\Actions\Root
29
 * @author TLe, Tarmo Leppänen <[email protected]>
30
 */
31
trait PatchAction
32
{
33
    use PatchMethod;
34
35
    /**
36
     * @throws Throwable
37
     */
38 3
    #[Route(
39
        path: '/{id}',
40
        requirements: [
41
            'id' => Requirement::UUID_V1,
42
        ],
43
        methods: [Request::METHOD_PATCH],
44
    )]
45
    #[IsGranted(Role::USER->value)]
46
    public function patchAction(Request $request, RestDtoInterface $restDto, string $id): Response
47
    {
48 3
        return $this->patchMethod($request, $restDto, $id);
49
    }
50
}
51