CreateAction::createAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 8
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Rest/Traits/Actions/Logged/CreateAction.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Rest\Traits\Actions\Logged;
10
11
use App\DTO\RestDtoInterface;
12
use App\Enum\Role;
13
use App\Rest\Traits\Methods\CreateMethod;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16
use Symfony\Component\Routing\Annotation\Route;
17
use Symfony\Component\Security\Http\Attribute\IsGranted;
18
use Throwable;
19
20
/**
21
 * Trait CreateAction
22
 *
23
 * Trait to add 'createAction' for REST controllers for 'ROLE_LOGGED' users.
24
 *
25
 * @see \App\Rest\Traits\Methods\CreateMethod for detailed documents.
26
 *
27
 * @package App\Rest\Traits\Actions\Logged
28
 * @author TLe, Tarmo Leppänen <[email protected]>
29
 */
30
trait CreateAction
31
{
32
    use CreateMethod;
33
34
    /**
35
     * @throws Throwable
36
     */
37 3
    #[Route(
38
        path: '',
39
        methods: [Request::METHOD_POST],
40
    )]
41
    #[IsGranted(Role::LOGGED->value)]
42
    public function createAction(Request $request, RestDtoInterface $restDto): Response
43
    {
44 3
        return $this->createMethod($request, $restDto);
45
    }
46
}
47