RecommendationsController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getUserRecommendations() 0 11 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