Completed
Push — master ( ea3b27...7da27d )
by Valentyn
03:13
created

MovieActorController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 6
dl 0
loc 33
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMoviesActors() 0 13 1
A test() 0 4 1
1
<?php
2
3
namespace App\Movies\Controller;
4
5
use App\Controller\BaseController;
6
use App\Movies\Repository\MovieActorRepository;
7
use App\Movies\Service\TmdbSearchService;
8
use App\Pagination\PaginatedCollection;
9
use Symfony\Component\HttpFoundation\JsonResponse;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\Routing\Annotation\Route;
12
13
class MovieActorController extends BaseController
14
{
15
    /**
16
     * @Route("/api/movies/{id}/actors", methods={"GET"}, requirements={"id"="\d+"})
17
     *
18
     * @param Request              $request
19
     * @param int                  $id
20
     * @param MovieActorRepository $repository
21
     *
22
     * @return JsonResponse
23
     */
24 1
    public function getMoviesActors(Request $request, int $id, MovieActorRepository $repository)
25
    {
26 1
        $actors = $repository->findAllByMovie($id);
27
28 1
        $offset = (int) $request->get('offset', 0);
29 1
        $limit = $request->get('limit', null);
30
31 1
        $collection = new PaginatedCollection($actors, $offset, $limit);
32
33 1
        return $this->response($collection, 200, [], [
34 1
            'groups' => ['list'],
35
        ]);
36
    }
37
38
    /**
39
     * @Route("/api/test", methods={"GET"})
40
     */
41
    public function test(TmdbSearchService $service)
42
    {
43
        return new JsonResponse($service->findMovieById(146));
44
    }
45
}
46