mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
Use abort_unless instead of abort_if where applicable
This commit is contained in:
parent
587d587bc9
commit
1386b0b809
3 changed files with 7 additions and 7 deletions
|
@ -38,7 +38,7 @@ class LastfmController extends Controller
|
|||
*/
|
||||
public function connect(Redirector $redirector, Lastfm $lastfm, JWTAuth $auth = null)
|
||||
{
|
||||
abort_if(!$lastfm->enabled(), 401, 'Koel is not configured to use with Last.fm yet.');
|
||||
abort_unless($lastfm->enabled(), 401, 'Koel is not configured to use with Last.fm yet.');
|
||||
|
||||
$auth = $auth ?: $this->app['tymon.jwt.auth'];
|
||||
|
||||
|
@ -64,10 +64,10 @@ class LastfmController extends Controller
|
|||
*/
|
||||
public function callback(Request $request, Lastfm $lastfm)
|
||||
{
|
||||
abort_if(!$token = $request->input('token'), 500, 'Something wrong happened.');
|
||||
abort_unless($token = $request->input('token'), 500, 'Something wrong happened.');
|
||||
|
||||
// Get the session key using the obtained token.
|
||||
abort_if(!$sessionKey = $lastfm->getSessionKey($token), 500, 'Invalid token key.');
|
||||
abort_unless($sessionKey = $lastfm->getSessionKey($token), 500, 'Invalid token key.');
|
||||
|
||||
$this->auth->user()->savePreference('lastfm_session_key', $sessionKey);
|
||||
|
||||
|
|
|
@ -43,13 +43,13 @@ class PHPStreamer extends Streamer implements StreamerInterface
|
|||
list($param, $range) = explode('=', $range);
|
||||
|
||||
// Bad request - range unit is not 'bytes'
|
||||
abort_if(strtolower(trim($param)) != 'bytes', 400);
|
||||
abort_unless(strtolower(trim($param)) === 'bytes', 400);
|
||||
|
||||
$range = explode(',', $range);
|
||||
$range = explode('-', $range[0]); // We only deal with the first requested range
|
||||
|
||||
// Bad request - 'bytes' parameter is not valid
|
||||
abort_if(count($range) != 2, 400);
|
||||
abort_unless(count($range) === 2, 400);
|
||||
|
||||
if ($range[0] === '') {
|
||||
// First number missing, return last $range[1] bytes
|
||||
|
@ -89,7 +89,7 @@ class PHPStreamer extends Streamer implements StreamerInterface
|
|||
header("Content-Range: bytes $start-$end/$fileSize");
|
||||
|
||||
// Error out if we can't read the file
|
||||
abort_if(!$fp = fopen($this->song->path, 'r'), 500);
|
||||
abort_unless($fp = fopen($this->song->path, 'r'), 500);
|
||||
|
||||
if ($start) {
|
||||
fseek($fp, $start);
|
||||
|
|
|
@ -25,7 +25,7 @@ class Streamer
|
|||
{
|
||||
$this->song = $song;
|
||||
|
||||
abort_if(!file_exists($this->song->path), 404);
|
||||
abort_unless(file_exists($this->song->path), 404);
|
||||
|
||||
// Hard code the content type instead of relying on PHP's fileinfo()
|
||||
// or even Symfony's MIMETypeGuesser, since they appear to be wrong sometimes.
|
||||
|
|
Loading…
Reference in a new issue