CountAction::countAction()   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 1
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/Root/CountAction.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\CountMethod;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Response;
15
use Symfony\Component\Routing\Annotation\Route;
16
use Symfony\Component\Security\Http\Attribute\IsGranted;
17
use Throwable;
18
19
/**
20
 * Trait CountAction
21
 *
22
 * Trait to add 'countAction' for REST controllers for 'ROLE_ROOT' users.
23
 *
24
 * @see \App\Rest\Traits\Methods\CountMethod for detailed documents.
25
 *
26
 * @package App\Rest\Traits\Actions\Root
27
 * @author TLe, Tarmo Leppänen <[email protected]>
28
 */
29
trait CountAction
30
{
31
    use CountMethod;
32
33
    /**
34
     * @throws Throwable
35
     */
36 5
    #[Route(
37
        path: '/count',
38
        methods: [Request::METHOD_GET],
39
    )]
40
    #[IsGranted(Role::ROOT->value)]
41
    public function countAction(Request $request): Response
42
    {
43 5
        return $this->countMethod($request);
44
    }
45
}
46