SongController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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