SongController   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 6
c 0
b 0
f 0
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
namespace App\Http\Controllers\API\Download;
4
5
use App\Http\Requests\API\Download\SongRequest;
6
use App\Repositories\SongRepository;
7
use App\Services\DownloadService;
8
9
/**
10
 * @group 6. Download
11
 */
12
class SongController extends Controller
13
{
14
    private $songRepository;
15
16 2
    public function __construct(DownloadService $downloadService, SongRepository $songRepository)
17
    {
18 2
        parent::__construct($downloadService);
19 2
        $this->songRepository = $songRepository;
20 2
    }
21
22
    /**
23
     * Download one or several songs.
24
     *
25
     * @queryParam songs array An array of song IDs
26
     *
27
     * @response []
28
     */
29 2
    public function show(SongRequest $request)
30
    {
31 2
        $songs = $this->songRepository->getByIds($request->songs);
32
33 2
        return response()->download($this->downloadService->from($songs));
34
    }
35
}
36