Test Setup Failed
Push — main ( abdcb9...2e5f68 )
by Slawomir
04:37
created

SecurityQueryController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPostsByUserId() 0 6 1
1
<?php
2
3
namespace App\Modules\Security\Api\Controller;
4
5
use App\Modules\Security\Api\Query\FindPostsByUserIdQuery;
6
use App\Modules\Security\Api\SecurityApiInterface;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\Routing\Annotation\Route;
11
use Symfony\Component\Uid\Ulid;
12
13
#[Route('/api/security')]
14
class SecurityQueryController extends AbstractController
15
{
16
17
    /**
18
     * @param SecurityApiInterface $securityApi
19
     */
20
    public function __construct(
21
        private SecurityApiInterface $securityApi
22
    )
23
    {
24
    }
25
26
    /**
27
     * @param string $userId
28
     * @return Response
29
     */
30
    #[Route('/{userId}', methods: ['GET'])]
31
    function getPostsByUserId(string $userId, Request $request): Response
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
    {
33
        $pageNo = $request->query->get("pageNo", "1");
34
        return $this->json(
35
            $this->securityApi->findPostsByUserId(new FindPostsByUserIdQuery(new Ulid($userId), intval($pageNo)))
36
        );
37
    }
38
}