Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2016-01-18 01:21:39 +00:00
parent 004c236ed4
commit d655d0a151
9 changed files with 122 additions and 116 deletions

View file

@ -43,25 +43,25 @@ class AlbumDownloader
function download()
{
$zip = new ZipStream($this->_album->user->display_name . ' - ' . $this->_album->title . '.zip');
$zip = new ZipStream($this->_album->user->display_name.' - '.$this->_album->title.'.zip');
$zip->setComment(
'Album: ' . $this->_album->title . "\r\n" .
'Artist: ' . $this->_album->user->display_name . "\r\n" .
'URL: ' . $this->_album->url . "\r\n" . "\r\n" .
'Downloaded on ' . date('l, F jS, Y, \a\t h:i:s A') . '.'
'Album: '.$this->_album->title."\r\n".
'Artist: '.$this->_album->user->display_name."\r\n".
'URL: '.$this->_album->url."\r\n"."\r\n".
'Downloaded on '.date('l, F jS, Y, \a\t h:i:s A').'.'
);
$directory = $this->_album->user->display_name . '/' . $this->_album->title . '/';
$directory = $this->_album->user->display_name.'/'.$this->_album->title.'/';
$notes =
'Album: ' . $this->_album->title . "\r\n" .
'Artist: ' . $this->_album->user->display_name . "\r\n" .
'URL: ' . $this->_album->url . "\r\n" .
"\r\n" .
$this->_album->description . "\r\n" .
"\r\n" .
"\r\n" .
'Tracks' . "\r\n" .
'Album: '.$this->_album->title."\r\n".
'Artist: '.$this->_album->user->display_name."\r\n".
'URL: '.$this->_album->url."\r\n".
"\r\n".
$this->_album->description."\r\n".
"\r\n".
"\r\n".
'Tracks'."\r\n".
"\r\n";
foreach ($this->_album->tracks as $track) {
@ -70,14 +70,14 @@ class AlbumDownloader
}
$zip->addLargeFile($track->getFileFor($this->_format),
$directory . $track->getDownloadFilenameFor($this->_format));
$directory.$track->getDownloadFilenameFor($this->_format));
$notes .=
$track->track_number . '. ' . $track->title . "\r\n" .
$track->description . "\r\n" .
$track->track_number.'. '.$track->title."\r\n".
$track->description."\r\n".
"\r\n";
}
$zip->addFile($notes, $directory . 'Album Notes.txt');
$zip->addFile($notes, $directory.'Album Notes.txt');
$zip->finalize();
}
}

View file

@ -80,7 +80,7 @@ class AuthController extends Controller
$setData = [
'access_token' => $code['result']['access_token'],
'expires' => date('Y-m-d H:i:s', strtotime("+" . $code['result']['expires_in'] . " Seconds", time())),
'expires' => date('Y-m-d H:i:s', strtotime("+".$code['result']['expires_in']." Seconds", time())),
'type' => $code['result']['token_type'],
];

View file

@ -22,7 +22,6 @@ namespace Poniverse\Ponyfm\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Response;
class DisabledAccountCheck
{
@ -59,7 +58,7 @@ class DisabledAccountCheck
if ($this->auth->check()
&& $this->auth->user()->disabled_at !== null
&& !($request->getMethod() === 'POST' && $request->getRequestUri() == '/auth/logout')
){
) {
$this->auth->logout();
// return Response::view('home.account-disabled', ['username' => $this->auth->user()->username], 403);
}

View file

@ -20,7 +20,6 @@
namespace Poniverse\Ponyfm\Http\Middleware;
use App;
use Closure;
use Cache;
use Config;
@ -58,7 +57,7 @@ class Profiler
$response = $this->processResponse($profiler, $response);
Log::listen(function ($level, $message, $context) use ($profiler, $request) {
Log::listen(function($level, $message, $context) use ($profiler, $request) {
$profiler->log($level, $message, $context);
});
@ -74,7 +73,7 @@ class Profiler
protected function processResponse(ProfileRequest $profiler, Response $response) {
$profiler->recordQueries();
Cache::put('profiler-request-' . $profiler->getId(), $profiler->toString(), 2);
Cache::put('profiler-request-'.$profiler->getId(), $profiler->toString(), 2);
return $response->header('X-Request-Id', $profiler->getId());
}
}

View file

@ -24,7 +24,6 @@ use Exception;
use Helpers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Auth;
use Cache;
use Poniverse\Ponyfm\Contracts\Searchable;
@ -80,7 +79,7 @@ class Album extends Model implements Searchable
{
if (Auth::check()) {
$query->with([
'users' => function ($query) {
'users' => function($query) {
$query->whereUserId(Auth::user()->id);
}
]);
@ -164,8 +163,8 @@ class Album extends Model implements Searchable
$data['is_downloadable'] = $is_downloadable;
$data['share'] = [
'url' => action('AlbumsController@getShortlink', ['id' => $album->id]),
'tumblrUrl' => 'http://www.tumblr.com/share/link?url=' . urlencode($album->url) . '&name=' . urlencode($album->title) . '&description=' . urlencode($album->description),
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $album->title . ' by ' . $album->user->display_name . ' on Pony.fm'
'tumblrUrl' => 'http://www.tumblr.com/share/link?url='.urlencode($album->url).'&name='.urlencode($album->title).'&description='.urlencode($album->description),
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text='.$album->title.' by '.$album->user->display_name.' on Pony.fm'
];
return $data;
@ -185,24 +184,24 @@ class Album extends Model implements Searchable
$userRow = $album->users[0];
$userData = [
'stats' => [
'views' => (int)$userRow->view_count,
'downloads' => (int)$userRow->download_count,
'views' => (int) $userRow->view_count,
'downloads' => (int) $userRow->download_count,
],
'is_favourited' => (bool)$userRow->is_favourited
'is_favourited' => (bool) $userRow->is_favourited
];
}
return [
'id' => (int)$album->id,
'track_count' => (int)$album->track_count,
'id' => (int) $album->id,
'track_count' => (int) $album->track_count,
'title' => $album->title,
'slug' => $album->slug,
'created_at' => $album->created_at->format('c'),
'stats' => [
'views' => (int)$album->view_count,
'downloads' => (int)$album->download_count,
'comments' => (int)$album->comment_count,
'favourites' => (int)$album->favourite_count
'views' => (int) $album->view_count,
'downloads' => (int) $album->download_count,
'comments' => (int) $album->comment_count,
'favourites' => (int) $album->favourite_count
],
'covers' => [
'small' => $album->getCoverUrl(Image::SMALL),
@ -211,7 +210,7 @@ class Album extends Model implements Searchable
],
'url' => $album->url,
'user' => [
'id' => (int)$album->user->id,
'id' => (int) $album->user->id,
'name' => $album->user->display_name,
'url' => $album->user->url,
],
@ -245,7 +244,7 @@ class Album extends Model implements Searchable
return 0;
}
return Cache::remember($this->getCacheKey('filesize-' . $format), 1440, function () use ($tracks, $format) {
return Cache::remember($this->getCacheKey('filesize-'.$format), 1440, function() use ($tracks, $format) {
$size = 0;
foreach ($tracks as $track) {
@ -277,9 +276,9 @@ class Album extends Model implements Searchable
public function getDirectory()
{
$dir = (string)(floor($this->id / 100) * 100);
$dir = (string) (floor($this->id / 100) * 100);
return \Config::get('ponyfm.files_directory') . '/tracks/' . $dir;
return \Config::get('ponyfm.files_directory').'/tracks/'.$dir;
}
public function getDates()
@ -384,13 +383,13 @@ class Album extends Model implements Searchable
}
foreach (Track::$Formats as $name => $format) {
Cache::forget($this->getCacheKey('filesize' . $name));
Cache::forget($this->getCacheKey('filesize'.$name));
}
}
public function getCacheKey($key)
{
return 'album-' . $this->id . '-' . $key;
return 'album-'.$this->id.'-'.$key;
}
/**

View file

@ -24,7 +24,6 @@ use Auth;
use Cache;
use Config;
use DB;
use Elasticsearch;
use Poniverse\Ponyfm\Contracts\Searchable;
use Poniverse\Ponyfm\Exceptions\TrackFileNotFoundException;
use Poniverse\Ponyfm\Traits\IndexedInElasticsearchTrait;
@ -211,7 +210,7 @@ class Track extends Model implements Searchable
{
if (Auth::check()) {
$query->with([
'users' => function ($query) {
'users' => function($query) {
$query->whereUserId(Auth::user()->id);
}
]);
@ -238,7 +237,7 @@ class Track extends Model implements Searchable
public function scopeWithComments($query)
{
$query->with([
'comments' => function ($query) {
'comments' => function($query) {
$query->with('user');
}
]);
@ -254,10 +253,13 @@ class Track extends Model implements Searchable
$query->join('mlpma_tracks', 'tracks.id', '=', 'mlpma_tracks.track_id');
}
/**
* @param integer $count
*/
public static function popular($count, $allowExplicit = false)
{
$trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5,
function () use ($allowExplicit, $count) {
$trackIds = Cache::remember('popular_tracks'.$count.'-'.($allowExplicit ? 'explicit' : 'safe'), 5,
function() use ($allowExplicit, $count) {
$query = static
::published()
->listed()
@ -342,12 +344,12 @@ class Track extends Model implements Searchable
$returnValue['share'] = [
'url' => action('TracksController@getShortlink', ['id' => $track->id]),
'html' => '<iframe src="' . action('TracksController@getEmbed', ['id' => $track->id]) . '" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
'bbcode' => '[url=' . $track->url . '][img]' . $track->getCoverUrl() . '[/img][/url]',
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text=' . $track->title . ' by ' . $track->user->display_name . ' on Pony.fm'
'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
'bbcode' => '[url='.$track->url.'][img]'.$track->getCoverUrl().'[/img][/url]',
'twitterUrl' => 'https://platform.twitter.com/widgets/tweet_button.html?text='.$track->title.' by '.$track->user->display_name.' on Pony.fm'
];
$returnValue['share']['tumblrUrl'] = 'http://www.tumblr.com/share/video?embed=' . urlencode($returnValue['share']['html']) . '&caption=' . urlencode($track->title);
$returnValue['share']['tumblrUrl'] = 'http://www.tumblr.com/share/video?embed='.urlencode($returnValue['share']['html']).'&caption='.urlencode($track->title);
$returnValue['formats'] = $formats;
@ -369,28 +371,28 @@ class Track extends Model implements Searchable
$userRow = $track->users[0];
$userData = [
'stats' => [
'views' => (int)$userRow->view_count,
'plays' => (int)$userRow->play_count,
'views' => (int) $userRow->view_count,
'plays' => (int) $userRow->play_count,
'downloads' => $userRow->download_count,
],
'is_favourited' => (bool)$userRow->is_favourited
'is_favourited' => (bool) $userRow->is_favourited
];
}
return [
'id' => (int)$track->id,
'id' => (int) $track->id,
'title' => $track->title,
'user' => [
'id' => (int)$track->user->id,
'id' => (int) $track->user->id,
'name' => $track->user->display_name,
'url' => $track->user->url
],
'stats' => [
'views' => (int)$track->view_count,
'plays' => (int)$track->play_count,
'downloads' => (int)$track->download_count,
'comments' => (int)$track->comment_count,
'favourites' => (int)$track->favourite_count
'views' => (int) $track->view_count,
'plays' => (int) $track->play_count,
'downloads' => (int) $track->download_count,
'comments' => (int) $track->comment_count,
'favourites' => (int) $track->favourite_count
],
'url' => $track->url,
'slug' => $track->slug,
@ -403,7 +405,7 @@ class Track extends Model implements Searchable
'genre' => $track->genre != null
?
[
'id' => (int)$track->genre->id,
'id' => (int) $track->genre->id,
'slug' => $track->genre->slug,
'name' => $track->genre->name
] : null,
@ -442,7 +444,7 @@ class Track extends Model implements Searchable
$returnValue['released_at'] = $track->released_at;
$returnValue['lyrics'] = $track->lyrics;
$returnValue['description'] = $track->description;
$returnValue['is_downloadable'] = !$track->isPublished() ? true : (bool)$track->is_downloadable;
$returnValue['is_downloadable'] = !$track->isPublished() ? true : (bool) $track->is_downloadable;
$returnValue['license_id'] = $track->license_id != null ? $track->license_id : 3;
return $returnValue;
@ -528,7 +530,7 @@ class Track extends Model implements Searchable
public function setTitleAttribute($value)
{
$this->setTitleAttributeSlug($value);;
$this->setTitleAttributeSlug($value); ;
$this->updateHash();
}
@ -567,7 +569,7 @@ class Track extends Model implements Searchable
public function getDownloadDirectoryAttribute()
{
if ($this->album) {
return $this->user->display_name . '/' . $this->album->title;
return $this->user->display_name.'/'.$this->album->title;
}
return $this->user->display_name;
@ -626,9 +628,9 @@ class Track extends Model implements Searchable
public function getDirectory()
{
$dir = (string)(floor($this->id / 100) * 100);
$dir = (string) (floor($this->id / 100) * 100);
return \Config::get('ponyfm.files_directory') . '/tracks/' . $dir;
return \Config::get('ponyfm.files_directory').'/tracks/'.$dir;
}
public function getDates()
@ -658,6 +660,9 @@ class Track extends Model implements Searchable
return "{$this->title}.{$format['extension']}";
}
/**
* @return string
*/
public function getFileFor($format)
{
if (!isset(self::$Formats[$format])) {
@ -677,7 +682,7 @@ class Track extends Model implements Searchable
* @return string
*/
public function getTemporarySourceFile() {
return Config::get('ponyfm.files_directory') . '/queued-tracks/' . $this->id;
return Config::get('ponyfm.files_directory').'/queued-tracks/'.$this->id;
}
@ -696,9 +701,9 @@ class Track extends Model implements Searchable
/**
* @return string one of the Track::STATUS_* values, indicating whether this track is currently being processed
*/
public function getStatusAttribute(){
return $this->trackFiles->reduce(function($carry, $trackFile){
if((int) $trackFile->status === TrackFile::STATUS_PROCESSING_ERROR) {
public function getStatusAttribute() {
return $this->trackFiles->reduce(function($carry, $trackFile) {
if ((int) $trackFile->status === TrackFile::STATUS_PROCESSING_ERROR) {
return static::STATUS_ERROR;
} elseif (
@ -721,7 +726,7 @@ class Track extends Model implements Searchable
public function updateHash()
{
$this->hash = md5(Helpers::sanitizeInputForHashing($this->user->display_name) . ' - ' . Helpers::sanitizeInputForHashing($this->title));
$this->hash = md5(Helpers::sanitizeInputForHashing($this->user->display_name).' - '.Helpers::sanitizeInputForHashing($this->title));
}
public function updateTags($trackFileFormat = 'all')
@ -750,22 +755,22 @@ class Track extends Model implements Searchable
/** @noinspection PhpUnusedPrivateMethodInspection */
private function updateTagsWithAtomicParsley($format)
{
$command = 'AtomicParsley "' . $this->getFileFor($format) . '" ';
$command .= '--title ' . escapeshellarg($this->title) . ' ';
$command .= '--artist ' . escapeshellarg($this->user->display_name) . ' ';
$command .= '--year "' . $this->year . '" ';
$command .= '--genre ' . escapeshellarg($this->genre != null ? $this->genre->name : '') . ' ';
$command .= '--copyright ' . escapeshellarg('© ' . $this->year . ' ' . $this->user->display_name) . ' ';
$command .= '--comment "' . 'Downloaded from: https://pony.fm/' . '" ';
$command .= '--encodingTool "' . 'Pony.fm - https://pony.fm/' . '" ';
$command = 'AtomicParsley "'.$this->getFileFor($format).'" ';
$command .= '--title '.escapeshellarg($this->title).' ';
$command .= '--artist '.escapeshellarg($this->user->display_name).' ';
$command .= '--year "'.$this->year.'" ';
$command .= '--genre '.escapeshellarg($this->genre != null ? $this->genre->name : '').' ';
$command .= '--copyright '.escapeshellarg('© '.$this->year.' '.$this->user->display_name).' ';
$command .= '--comment "'.'Downloaded from: https://pony.fm/'.'" ';
$command .= '--encodingTool "'.'Pony.fm - https://pony.fm/'.'" ';
if ($this->album_id !== null) {
$command .= '--album ' . escapeshellarg($this->album->title) . ' ';
$command .= '--tracknum ' . $this->track_number . ' ';
$command .= '--album '.escapeshellarg($this->album->title).' ';
$command .= '--tracknum '.$this->track_number.' ';
}
if ($this->cover !== null) {
$command .= '--artwork ' . $this->cover->getFile(Image::ORIGINAL) . ' ';
$command .= '--artwork '.$this->cover->getFile(Image::ORIGINAL).' ';
}
$command .= '--overWrite';
@ -776,8 +781,8 @@ class Track extends Model implements Searchable
/** @noinspection PhpUnusedPrivateMethodInspection */
private function updateTagsWithGetId3($format)
{
require_once(app_path() . '/Library/getid3/getid3/getid3.php');
require_once(app_path() . '/Library/getid3/getid3/write.php');
require_once(app_path().'/Library/getid3/getid3/getid3.php');
require_once(app_path().'/Library/getid3/getid3/write.php');
$tagWriter = new getid3_writetags;
$tagWriter->overwrite_tags = true;
@ -787,10 +792,10 @@ class Track extends Model implements Searchable
$tagWriter->tag_data = [
'title' => [$this->title],
'artist' => [$this->user->display_name],
'year' => ['' . $this->year],
'year' => [''.$this->year],
'genre' => [$this->genre != null ? $this->genre->name : ''],
'comment' => ['Downloaded from: https://pony.fm/'],
'copyright' => ['© ' . $this->year . ' ' . $this->user->display_name],
'copyright' => ['© '.$this->year.' '.$this->user->display_name],
'publisher' => ['Pony.fm - https://pony.fm/'],
'encoded_by' => ['https://pony.fm/'],
// 'url_artist' => [$this->user->url],
@ -818,18 +823,18 @@ class Track extends Model implements Searchable
if ($tagWriter->WriteTags()) {
if (!empty($tagWriter->warnings)) {
Log::warning('Track #' . $this->id . ': There were some warnings:<br />' . implode('<br /><br />',
Log::warning('Track #'.$this->id.': There were some warnings:<br />'.implode('<br /><br />',
$tagWriter->warnings));
}
} else {
Log::error('Track #' . $this->id . ': Failed to write tags!<br />' . implode('<br /><br />',
Log::error('Track #'.$this->id.': Failed to write tags!<br />'.implode('<br /><br />',
$tagWriter->errors));
}
}
private function getCacheKey($key)
{
return 'track-' . $this->id . '-' . $key;
return 'track-'.$this->id.'-'.$key;
}

View file

@ -88,7 +88,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
{
if (Auth::check()) {
$query->with([
'users' => function ($query) {
'users' => function($query) {
$query->whereUserId(Auth::user()->id);
}
]);
@ -151,7 +151,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function getIsArchivedAttribute()
{
return (bool)$this->attributes['is_archived'];
return (bool) $this->attributes['is_archived'];
}
public function getUrlAttribute()
@ -161,7 +161,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function getMessageUrlAttribute()
{
return 'http://mlpforums.com/index.php?app=members&module=messaging&section=send&do=form&fromMemberID=' . $this->id;
return 'http://mlpforums.com/index.php?app=members&module=messaging&section=send&do=form&fromMemberID='.$this->id;
}
public function getAuthIdentifier()
@ -192,7 +192,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
}
if ($this->email == "redacted@example.net") {
return Gravatar::getUrl($this->id . "", Image::$ImageTypes[$type]['width'], "identicon");
return Gravatar::getUrl($this->id."", Image::$ImageTypes[$type]['width'], "identicon");
}
$email = $this->gravatar;
@ -238,7 +238,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
/**
* Returns true if this user has the given role.
*
* @param $roleName
* @param string $roleName
* @return bool
*/
public function hasRole($roleName)

View file

@ -43,23 +43,23 @@ class PlaylistDownloader
function download()
{
$zip = new ZipStream($this->_playlist->user->display_name . ' - ' . $this->_playlist->title . '.zip');
$zip = new ZipStream($this->_playlist->user->display_name.' - '.$this->_playlist->title.'.zip');
$zip->setComment(
'Playlist: ' . $this->_playlist->title . "\r\n" .
'Curator: ' . $this->_playlist->user->display_name . "\r\n" .
'URL: ' . $this->_playlist->url . "\r\n" . "\r\n" .
'Downloaded on ' . date('l, F jS, Y, \a\t h:i:s A') . '.'
'Playlist: '.$this->_playlist->title."\r\n".
'Curator: '.$this->_playlist->user->display_name."\r\n".
'URL: '.$this->_playlist->url."\r\n"."\r\n".
'Downloaded on '.date('l, F jS, Y, \a\t h:i:s A').'.'
);
$notes =
'Playlist: ' . $this->_playlist->title . "\r\n" .
'Curator: ' . $this->_playlist->user->display_name . "\r\n" .
'URL: ' . $this->_playlist->url . "\r\n" .
"\r\n" .
$this->_playlist->description . "\r\n" .
"\r\n" .
"\r\n" .
'Tracks' . "\r\n" .
'Playlist: '.$this->_playlist->title."\r\n".
'Curator: '.$this->_playlist->user->display_name."\r\n".
'URL: '.$this->_playlist->url."\r\n".
"\r\n".
$this->_playlist->description."\r\n".
"\r\n".
"\r\n".
'Tracks'."\r\n".
"\r\n";
$m3u = '';
@ -69,22 +69,22 @@ class PlaylistDownloader
continue;
}
$trackTarget = $track->downloadDirectory . '/' . $track->getDownloadFilenameFor($this->_format);
$trackTarget = $track->downloadDirectory.'/'.$track->getDownloadFilenameFor($this->_format);
$zip->addLargeFile($track->getFileFor($this->_format), $trackTarget);
$notes .=
$index . '. ' . $track->title . "\r\n" .
$track->description . "\r\n" .
$index.'. '.$track->title."\r\n".
$track->description."\r\n".
"\r\n";
$m3u .= '#EXTINF:' . $track->duration . ',' . $track->title . "\r\n";
$m3u .= '../' . $trackTarget . "\r\n";
$m3u .= '#EXTINF:'.$track->duration.','.$track->title."\r\n";
$m3u .= '../'.$trackTarget."\r\n";
$index++;
}
$playlistDir = 'Pony.fm Playlists/';
$zip->addFile($notes, $playlistDir . $this->_playlist->title . '.txt');
$zip->addFile($m3u, $playlistDir . $this->_playlist->title . '.m3u');
$zip->addFile($notes, $playlistDir.$this->_playlist->title.'.txt');
$zip->addFile($m3u, $playlistDir.$this->_playlist->title.'.m3u');
$zip->finalize();
}
}

View file

@ -87,6 +87,10 @@ class ProfileRequest
}
}
/**
* @param string $level
* @param string $message
*/
public function log($level, $message, $context)
{
$this->_data['log'][] = [