Issues (49)

app/Http/Controllers/API/iTunesController.php (1 issue)

Labels
1
<?php
2
3
namespace App\Http\Controllers\API;
4
5
use App\Http\Requests\API\ViewSongOnITunesRequest;
6
use App\Models\Album;
7
use App\Services\iTunesService;
8
use Illuminate\Http\RedirectResponse;
9
10
class iTunesController extends Controller
11
{
12
    private $iTunesService;
13
14
    public function __construct(iTunesService $iTunesService)
15
    {
16
        $this->iTunesService = $iTunesService;
17
    }
18
19
    /**
20
     * View a song on iTunes store.
21
     *
22
     * @return RedirectResponse
23
     */
24
    public function viewSong(ViewSongOnITunesRequest $request, Album $album)
25
    {
26
        $url = $this->iTunesService->getTrackUrl($request->q, $album->name, $album->artist->name);
27
        abort_unless($url, 404, "Koel can't find such a song on iTunes Store.");
0 ignored issues
show
It seems like $url can also be of type string; however, parameter $boolean of abort_unless() does only seem to accept boolean, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        abort_unless(/** @scrutinizer ignore-type */ $url, 404, "Koel can't find such a song on iTunes Store.");
Loading history...
28
29
        return redirect($url);
30
    }
31
}
32