Issues (12)

src/Service/User/PropertyService.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Service\User;
6
7
use App\Repository\UserPropertyRepository;
8
use App\Transformer\RequestToArrayTransformer;
9
use Knp\Component\Pager\Pagination\PaginationInterface;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
12
13
final class PropertyService
14
{
15
    private UserPropertyRepository $repository;
16
    private RequestToArrayTransformer $transformer;
17
    private TokenStorageInterface $tokenStorage;
18
19
    public function __construct(
20
        UserPropertyRepository $repository,
21
        RequestToArrayTransformer $transformer,
22
        TokenStorageInterface $tokenStorage
23
    ) {
24
        $this->repository = $repository;
25
        $this->transformer = $transformer;
26
        $this->tokenStorage = $tokenStorage;
27
    }
28
29
    public function getUserProperties(Request $request): PaginationInterface
30
    {
31
        $searchParams = $this->transformer->transform($request);
32
        $searchParams['user'] = $this->tokenStorage->getToken()->getUser()->getId();
0 ignored issues
show
The method getId() does not exist on Symfony\Component\Security\Core\User\UserInterface. It seems like you code against a sub-type of Symfony\Component\Security\Core\User\UserInterface such as App\Entity\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $searchParams['user'] = $this->tokenStorage->getToken()->getUser()->/** @scrutinizer ignore-call */ getId();
Loading history...
33
34
        return $this->repository->findByUser($searchParams);
35
    }
36
}
37