SongController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 7 1
A __construct() 0 4 1
1
<?php
2
3
namespace App\Http\Controllers\API\MediaInformation;
4
5
use App\Models\Song;
6
use App\Services\MediaInformationService;
7
use App\Services\YouTubeService;
8
use Illuminate\Http\JsonResponse;
9
10
/**
11
 * @group 5. Media information
12
 */
13
class SongController extends Controller
14
{
15
    private $youTubeService;
16
17
    public function __construct(MediaInformationService $mediaInformationService, YouTubeService $youTubeService)
18
    {
19
        parent::__construct($mediaInformationService);
20
        $this->youTubeService = $youTubeService;
21
    }
22
23
    /**
24
     * Get song's extra information.
25
     *
26
     * Get a song's extra information. The response of this request is a superset of both corresponding
27
     * `album/{album}/info` and `artist/{artist}/info` requests, combined with the song's lyrics and related YouTube
28
     * videos, if applicable. This means you can (and should) cache this information somewhere ;)
29
     *
30
     * @responseFile responses/mediaInformation.song.show.json
31
     *
32
     * @return JsonResponse
33
     */
34
    public function show(Song $song)
35
    {
36
        return response()->json([
37
            'lyrics' => $song->lyrics,
38
            'album_info' => $this->mediaInformationService->getAlbumInformation($song->album),
39
            'artist_info' => $this->mediaInformationService->getArtistInformation($song->artist),
40
            'youtube' => $this->youTubeService->searchVideosRelatedToSong($song),
41
        ]);
42
    }
43
}
44