Skip to content

Commit

Permalink
Apply fixes from StyleCI (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane authored Apr 19, 2019
1 parent 8bab369 commit 8eb174a
Show file tree
Hide file tree
Showing 39 changed files with 64 additions and 57 deletions.
1 change: 1 addition & 0 deletions app/Console/Commands/ExecuteInstallation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function handle()
{
if (\App\Http\Controllers\SetupController::checkTablesExist()) {
$this->info('You have installed Blessing Skin Server. Nothing to do.');

return;
}

Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function chartData()

$xAxis = Collection::times(30, function ($number) use ($today) {
$time = Carbon::createFromTimestamp($today - (31 - $number) * 86400);

return $time->format('m-d');
});

Expand Down Expand Up @@ -57,13 +58,13 @@ public function chartData()
return [
'labels' => [
trans('admin.index.user-registration'),
trans('admin.index.texture-uploads')
trans('admin.index.texture-uploads'),
],
'xAxis' => $xAxis,
'data' => [
$xAxis->map($aligning($userRegistration)),
$xAxis->map($aligning($textureUploads)),
]
],
];
}

Expand Down Expand Up @@ -108,7 +109,7 @@ public function customize(Request $request)

return view('admin.customize', [
'forms' => compact('homepage', 'customJsCss'),
'extra' => ['currentSkin' => option('color_scheme')]
'extra' => ['currentSkin' => option('color_scheme')],
]);
}

Expand Down Expand Up @@ -455,7 +456,7 @@ public function userAjaxHandler(Request $request)
return json(trans('admin.users.operations.score.success'), 0);
} elseif ($action == 'permission') {
$user->permission = $this->validate($request, [
'permission' => 'required|in:-1,0,1'
'permission' => 'required|in:-1,0,1',
])['permission'];
$user->save();

Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function logout()
{
if (Auth::check()) {
Auth::logout();

return json(trans('auth.logout.success'), 0);
} else {
return json(trans('auth.logout.fail'), 1);
Expand All @@ -89,7 +90,7 @@ public function register()
'player' => (bool) option('register_with_player_name'),
'recaptcha' => option('recaptcha_sitekey'),
'invisible' => (bool) option('recaptcha_invisible'),
]
],
]);
} else {
throw new PrettyPageException(trans('auth.register.close'), 7);
Expand Down Expand Up @@ -166,7 +167,7 @@ public function forgot()
'extra' => [
'recaptcha' => option('recaptcha_sitekey'),
'invisible' => (bool) option('recaptcha_invisible'),
]
],
]);
} else {
throw new PrettyPageException(trans('auth.forgot.disabled'), 8);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/MarketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers;

use Exception;
use ZipArchive;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use App\Services\PluginManager;
Expand Down Expand Up @@ -93,6 +92,7 @@ public function download(Request $request, PluginManager $manager, PackageManage
} catch (Exception $e) {
return json($e->getMessage(), 1);
}

return json(trans('admin.plugins.market.install-success'), 0);
}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/PlayerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function index()
'length' => trans(
'user.player.player-name-length',
['min' => option('player_name_length_min'), 'max' => option('player_name_length_max')]
)
),
]);
}

Expand Down Expand Up @@ -186,6 +186,7 @@ public function clearTexture(Request $request)
}
}, ['skin', 'cape']);
$this->player->save();

return json(trans('user.player.clear.success', ['name' => $this->player->name]), 0);
}

Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function submit(Request $request)
{
$data = $this->validate($request, [
'tid' => 'required|exists:textures',
'reason' => 'required'
'reason' => 'required',
]);
$reporter = auth()->user();

Expand Down Expand Up @@ -71,6 +71,7 @@ public function manage(Request $request)
if ($report->informer) {
$report->reporterName = $report->informer->nickname;
}

return $report;
});

Expand All @@ -84,7 +85,7 @@ public function review(Request $request)
{
$data = $this->validate($request, [
'id' => 'required|exists:reports',
'action' => ['required', Rule::in(['delete', 'ban', 'reject'])]
'action' => ['required', Rule::in(['delete', 'ban', 'reject'])],
]);
$report = Report::find($data['id']);

Expand All @@ -102,6 +103,7 @@ public function review(Request $request)
}
$report->status = Report::REJECTED;
$report->save();

return json(trans('general.op-success'), 0, ['status' => Report::REJECTED]);
}

Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function database(Request $request)
if ($request->isMethod('get')) {
try {
DB::getPdo();

return redirect('setup/info');
// @codeCoverageIgnoreStart
} catch (\Exception $e) {
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/TextureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function avatarByTid($tid, $size = 128)
return $responses[0]; // @codeCoverageIgnore
} else {
$png = Minecraft::generateAvatarFromSkin(Storage::disk('textures')->read($t->hash), $size);

return Response::png(png($png));
}
}
Expand Down Expand Up @@ -209,6 +210,7 @@ protected function getPlayerInstance($player_name)
{
$player = Player::where('name', $player_name)->first();
abort_if($player->isBanned(), 403, trans('general.player-banned'));

return $player;
}

Expand Down
6 changes: 5 additions & 1 deletion app/Http/Controllers/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use Log;
use Exception;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -32,6 +31,7 @@ public function showUpdatePage()
];
$error = $this->error;
$extra = ['canUpdate' => $this->canUpdate()];

return view('admin.update', compact('info', 'error', 'extra'));
}

Expand All @@ -51,9 +51,11 @@ public function download(Request $request, PackageManager $package)
case 'download':
try {
$package->download($this->info['url'], $path)->extract(base_path());

return json(trans('admin.update.complete'), 0);
} catch (Exception $e) {
report($e);

return json($e->getMessage(), 1);
}
case 'progress':
Expand All @@ -79,12 +81,14 @@ protected function getUpdateInfo()
$this->error = $e->getMessage();
}
}

return $this->info;
}

protected function canUpdate()
{
$this->getUpdateInfo();

return Comparator::greaterThan(Arr::get($this->info, 'latest'), $this->currentVersion);
}
}
3 changes: 3 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public function sendVerificationEmail()
public function profile()
{
$user = Auth::user();

return view('user.profile')
->with('extra', [
'unverified' => option('require_verification') && ! $user->verified,
Expand Down Expand Up @@ -282,6 +283,7 @@ public function setAvatar(Request $request)
if ($tid == 0) {
$user->avatar = 0;
$user->save();

return json(trans('user.profile.avatar.success'), 0);
}

Expand All @@ -293,6 +295,7 @@ public function setAvatar(Request $request)

$user->avatar = $tid;
$user->save();

return json(trans('user.profile.avatar.success'), 0);
} else {
return json(trans('skinlib.non-existent'), 1);
Expand Down
1 change: 1 addition & 0 deletions app/Http/Middleware/CheckAdministrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CheckAdministrator
public function handle($request, \Closure $next)
{
abort_unless(auth()->user()->isAdmin(), 403, trans('auth.check.admin'));

return $next($request);
}
}
1 change: 1 addition & 0 deletions app/Http/Middleware/CheckSuperAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CheckSuperAdmin
public function handle($request, Closure $next)
{
abort_if(auth()->user()->permission != User::SUPER_ADMIN, 403, trans('auth.check.super-admin'));

return $next($request);
}
}
1 change: 1 addition & 0 deletions app/Http/Middleware/CheckUserVerified.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CheckUserVerified
public function handle($request, \Closure $next)
{
abort_if(option('require_verification') && ! auth()->user()->verified, 403, trans('auth.check.verified'));

return $next($request);
}
}
1 change: 1 addition & 0 deletions app/Listeners/CacheAvatarPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function handle(GetAvatarPreview $event)

$content = Cache::rememberForever($key, function () use ($texture, $size) {
$res = Storage::disk('textures')->read($texture->hash);

return png(Minecraft::generateAvatarFromSkin($res, $size));
});

Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/CachePlayerExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Listeners;

use Cache;
use Storage;
use App\Events;
use App\Models\Player;
use Illuminate\Events\Dispatcher;
Expand All @@ -25,6 +24,7 @@ public function remember(Events\CheckPlayerExists $event)

if (! $player) {
Cache::forever($key, '1');

return false;
} else {
return true;
Expand Down
1 change: 0 additions & 1 deletion app/Listeners/CachePlayerJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Listeners;

use Cache;
use Storage;
use App\Models\Player;
use App\Events\GetPlayerJson;
use App\Events\PlayerProfileUpdated;
Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/CacheSkinPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function handle(\App\Events\GetSkinPreview $event)
});

return response()->png($content, 200, [
'Last-Modified' => Storage::disk('textures')->lastModified($texture->hash)
'Last-Modified' => Storage::disk('textures')->lastModified($texture->hash),
]);
}
}
2 changes: 1 addition & 1 deletion app/Models/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Report extends Model
public const CREATED_AT = 'report_at';
public const UPDATED_AT = null;

public const PENDING = 0;
public const PENDING = 0;
public const RESOLVED = 1;
public const REJECTED = 2;

Expand Down
1 change: 1 addition & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function closet()
public function getPlayerNameAttribute()
{
$player = $this->players->first();

return $player ? $player->name : '';
}

Expand Down
3 changes: 2 additions & 1 deletion app/Rules/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public function passes($attribute, $value)
'form_params' => [
'secret' => $secretkey,
'response' => $value,
]
],
]);
if ($response->getStatusCode() == 200) {
$body = json_decode((string) $response->getBody());

return $body->success;
}
} catch (\GuzzleHttp\Exception\RequestException $e) {
Expand Down
2 changes: 1 addition & 1 deletion app/Services/PackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function download($url, $path, $shasum = null)
try {
$this->guzzle->request('GET', $url, [
'sink' => $path,
'progress' => $this->onProgress
'progress' => $this->onProgress,
]);
} catch (Exception $e) {
throw new Exception(trans('admin.download.errors.download', ['error' => $e->getMessage()]));
Expand Down
6 changes: 0 additions & 6 deletions app/Services/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,11 @@ public function __construct($path, $packageInfo)
$this->packageInfo = $packageInfo;
}

/**
* {@inheritdoc}
*/
public function __get($name)
{
return $this->packageInfoAttribute(snake_case($name, '-'));
}

/**
* {@inheritdoc}
*/
public function __isset($name)
{
return isset($this->{$name}) || $this->packageInfoAttribute(snake_case($name, '-'));
Expand Down
1 change: 0 additions & 1 deletion app/Services/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Storage;
use App\Events;
use App\Services\Option;
use Composer\Semver\Semver;
use Illuminate\Support\Arr;
use Composer\Semver\Comparator;
Expand Down
4 changes: 3 additions & 1 deletion app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Carbon\Carbon;
use App\Models\User;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

if (! function_exists('webpack_assets')) {
function webpack_assets($relativeUri)
Expand All @@ -13,6 +12,7 @@ function webpack_assets($relativeUri)
} else {
$path = app('webpack')->$relativeUri;
$cdn = option('cdn_address');

return $cdn ? "$cdn/app/$path" : url("/app/$path");
}
}
Expand Down Expand Up @@ -192,6 +192,7 @@ function option($key = null, $default = null, $raw = false)

if (is_array($key)) {
$options->set($key);

return;
}

Expand Down Expand Up @@ -360,6 +361,7 @@ function png($resource)
$image = ob_get_contents();
ob_end_clean();
imagedestroy($resource);

return $image;
}
}
Loading

0 comments on commit 8eb174a

Please sign in to comment.