Bump Laravel version and use some syntax sugar

This commit is contained in:
An Phan 2016-03-11 18:13:13 +08:00
parent 03e8dbd6b9
commit 587d587bc9
4 changed files with 28 additions and 42 deletions

View file

@ -38,9 +38,7 @@ class LastfmController extends Controller
*/
public function connect(Redirector $redirector, Lastfm $lastfm, JWTAuth $auth = null)
{
if (!$lastfm->enabled()) {
abort(401, 'Koel is not configured to use with Last.fm yet.');
}
abort_if(!$lastfm->enabled(), 401, 'Koel is not configured to use with Last.fm yet.');
$auth = $auth ?: $this->app['tymon.jwt.auth'];
@ -66,14 +64,10 @@ class LastfmController extends Controller
*/
public function callback(Request $request, Lastfm $lastfm)
{
if (!$token = $request->input('token')) {
abort(500, 'Something wrong happened.');
}
abort_if(!$token = $request->input('token'), 500, 'Something wrong happened.');
// Get the session key using the obtained token.
if (!$sessionKey = $lastfm->getSessionKey($token)) {
abort(500, 'Invalid token key.');
}
abort_if(!$sessionKey = $lastfm->getSessionKey($token), 500, 'Invalid token key.');
$this->auth->user()->savePreference('lastfm_session_key', $sessionKey);

View file

@ -42,18 +42,14 @@ class PHPStreamer extends Streamer implements StreamerInterface
$partial = true;
list($param, $range) = explode('=', $range);
if (strtolower(trim($param)) != 'bytes') {
// Bad request - range unit is not 'bytes'
abort(400);
}
// Bad request - range unit is not 'bytes'
abort_if(strtolower(trim($param)) != 'bytes', 400);
$range = explode(',', $range);
$range = explode('-', $range[0]); // We only deal with the first requested range
if (count($range) != 2) {
// Bad request - 'bytes' parameter is not valid
abort(400);
}
// Bad request - 'bytes' parameter is not valid
abort_if(count($range) != 2, 400);
if ($range[0] === '') {
// First number missing, return last $range[1] bytes
@ -92,10 +88,8 @@ class PHPStreamer extends Streamer implements StreamerInterface
header('HTTP/1.1 206 Partial Content');
header("Content-Range: bytes $start-$end/$fileSize");
if (!$fp = fopen($this->song->path, 'r')) {
// Error out if we can't read the file
abort(500);
}
// Error out if we can't read the file
abort_if(!$fp = fopen($this->song->path, 'r'), 500);
if ($start) {
fseek($fp, $start);

View file

@ -25,9 +25,7 @@ class Streamer
{
$this->song = $song;
if (!file_exists($this->song->path)) {
abort(404);
}
abort_if(!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.

36
composer.lock generated
View file

@ -288,16 +288,16 @@
},
{
"name": "guzzlehttp/promises",
"version": "1.0.3",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea"
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8",
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8",
"shasum": ""
},
"require": {
@ -335,7 +335,7 @@
"keywords": [
"promise"
],
"time": "2015-10-15 22:28:00"
"time": "2016-03-08 01:15:46"
},
{
"name": "guzzlehttp/psr7",
@ -706,16 +706,16 @@
},
{
"name": "league/flysystem",
"version": "1.0.17",
"version": "1.0.18",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "02f5b6c9a8b9278c8381e3361e7bd9d641c740ca"
"reference": "b334d6c5f95364948e06d2f620ab93d084074c6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/02f5b6c9a8b9278c8381e3361e7bd9d641c740ca",
"reference": "02f5b6c9a8b9278c8381e3361e7bd9d641c740ca",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/b334d6c5f95364948e06d2f620ab93d084074c6e",
"reference": "b334d6c5f95364948e06d2f620ab93d084074c6e",
"shasum": ""
},
"require": {
@ -785,7 +785,7 @@
"sftp",
"storage"
],
"time": "2016-02-19 15:35:38"
"time": "2016-03-07 21:01:43"
},
{
"name": "monolog/monolog",
@ -1389,16 +1389,16 @@
},
{
"name": "psy/psysh",
"version": "v0.7.1",
"version": "v0.7.2",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "5e8cedbe0a3681f18782594eefc78423f8401fc8"
"reference": "e64e10b20f8d229cac76399e1f3edddb57a0f280"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/5e8cedbe0a3681f18782594eefc78423f8401fc8",
"reference": "5e8cedbe0a3681f18782594eefc78423f8401fc8",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/e64e10b20f8d229cac76399e1f3edddb57a0f280",
"reference": "e64e10b20f8d229cac76399e1f3edddb57a0f280",
"shasum": ""
},
"require": {
@ -1457,7 +1457,7 @@
"interactive",
"shell"
],
"time": "2016-02-27 18:59:18"
"time": "2016-03-09 05:03:14"
},
{
"name": "swiftmailer/swiftmailer",
@ -1930,7 +1930,7 @@
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
@ -1989,7 +1989,7 @@
},
{
"name": "symfony/polyfill-php56",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
@ -2045,7 +2045,7 @@
},
{
"name": "symfony/polyfill-util",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-util.git",