Test Failed
Push — develop ( 7c3d28...e1debf )
by BENARD
12:55 queued 06:18
created

GetRelatedVideos   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\Controller\Video;
6
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpKernel\Attribute\AsController;
10
use VideoGamesRecords\CoreBundle\Entity\Video;
11
use VideoGamesRecords\CoreBundle\Service\VideoRecommendationService;
12
13
#[AsController]
14
class GetRelatedVideos extends AbstractController
15
{
16
    public function __construct(
17
        private readonly VideoRecommendationService $videoRecommendationService
18
    ) {
19
    }
20
21
    public function __invoke(Video $data, Request $request): array
22
    {
23
        $limit = min(20, max(1, (int) $request->query->get('limit', 10)));
24
25
        return $this->videoRecommendationService->getRelatedVideos($data, $limit);
26
    }
27
}
28