getUserRecommendations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace App\Users\Controller;
4
5
use App\Controller\BaseController;
6
use App\Movies\Repository\MovieRecommendationRepository;
7
use App\Movies\Transformer\UserRecommendationTransformer;
8
use App\Pagination\CustomPaginatedCollection;
9
use App\Users\Entity\User;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\Routing\Annotation\Route;
13
14
class RecommendationsController extends BaseController
15
{
16
    /**
17
     * @Route("/api/users/{id<\d+>}/recommendations", methods={"GET"})
18
     *
19
     * @param User                          $profileOwner
20
     * @param Request                       $request
21
     * @param MovieRecommendationRepository $repository
22
     *
23
     * @throws
24
     *
25
     * @return JsonResponse
26
     */
27 2
    public function getUserRecommendations(User $profileOwner, Request $request, MovieRecommendationRepository $repository)
28
    {
29 2
        $offset = (int) $request->get('offset', 0);
30 2
        $limit = $request->get('limit', null);
31 2
        $minRating = (int) $request->get('minRating', 7);
32
33 2
        [$items, $ids, $count] = $repository->findAllByUser($profileOwner->getId(), abs($minRating), $this->getUser());
0 ignored issues
show
Bug introduced by
The variable $items does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $ids does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $count does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
34 2
        $collection = new CustomPaginatedCollection($items, $ids, $count, $offset, $limit);
35
36 2
        return $this->items($collection, UserRecommendationTransformer::list($collection->getItemsIds()));
37
    }
38
}
39