FindOneAction::findOneAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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