YouTubeController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 4
c 0
b 0
f 0
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A searchVideosRelatedToSong() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace App\Http\Controllers\API;
4
5
use App\Http\Requests\API\YouTubeSearchRequest;
6
use App\Models\Song;
7
use App\Services\YouTubeService;
8
use Illuminate\Http\JsonResponse;
9
10
/**
11
 * @group YouTube integration
12
 */
13
class YouTubeController extends Controller
14
{
15
    private $youTubeService;
16
17 1
    public function __construct(YouTubeService $youTubeService)
18
    {
19 1
        $this->youTubeService = $youTubeService;
20 1
    }
21
22
    /**
23
     * Search for YouTube videos.
24
     *
25
     * Search YouTube for videos related to a song (using its title and artist name).
26
     *
27
     * @bodyParam pageToken string The [`nextPageToken`](https://developers.google.com/youtube/v3/guides/implementation/pagination), if applicable.
28
     * @responseFile responses/youTube.searchVideosRelatedToSong.json
29
     *
30
     * @return JsonResponse
31
     */
32 1
    public function searchVideosRelatedToSong(YouTubeSearchRequest $request, Song $song)
33
    {
34 1
        return response()->json($this->youTubeService->searchVideosRelatedToSong($song, $request->pageToken));
35
    }
36
}
37