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

SecurityQueryController::getPostsByUserId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
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
}