Apply fixes from StyleCI

This commit is contained in:
Dane Everitt 2016-12-07 22:46:38 +00:00 committed by StyleCI Bot
parent a1d3bbf73d
commit c1fb0a665f
150 changed files with 1558 additions and 1760 deletions

View file

@ -1,7 +1,7 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,16 +21,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Services;
use Log;
use Illuminate\Http\Request;
use Pterodactyl\Models\APILog;
class APILogService
{
public function __constructor()
{
//
@ -38,7 +37,7 @@ class APILogService
public static function log(Request $request, $error = null, $authorized = false)
{
if ($request->bearerToken() && !empty($request->bearerToken())) {
if ($request->bearerToken() && ! empty($request->bearerToken())) {
list($public, $hashed) = explode('.', $request->bearerToken());
} else {
$public = null;
@ -53,7 +52,7 @@ class APILogService
'route' => $request->fullUrl(),
'content' => (empty($request->getContent())) ? null : $request->getContent(),
'user_agent' => $request->header('User-Agent'),
'request_ip' => $request->ip()
'request_ip' => $request->ip(),
]);
$log->save();
} catch (\Exception $ex) {

View file

@ -1,7 +1,7 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,16 +21,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Services;
use DB;
use Pterodactyl\Models;
use Pterodactyl\Exceptions\DisplayException;
class DeploymentService
{
public function __constructor()
{
//
@ -62,12 +61,12 @@ class DeploymentService
public static function randomNode($location, array $not = [])
{
$useLocation = Models\Location::where('id', $location)->first();
if (!$useLocation) {
throw new DisplayException("The location passed was not valid and could not be found.");
if (! $useLocation) {
throw new DisplayException('The location passed was not valid and could not be found.');
}
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
if (!$node) {
if (! $node) {
throw new DisplayException("Unable to find a node in location {$useLocation->short} (id: {$useLocation->id}) that is available and has space.");
}
@ -84,18 +83,19 @@ class DeploymentService
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public static function smartRandomNode($memory, $disk, $location = null) {
public static function smartRandomNode($memory, $disk, $location = null)
{
$node = self::randomNode($location);
$notIn = [];
do {
$return = self::checkNodeAllocation($node, $memory, $disk);
if (!$return) {
if (! $return) {
$notIn = array_merge($notIn, [
$node->id
$node->id,
]);
$node = self::randomNode($location, $notIn);
}
} while (!$return);
} while (! $return);
return $node;
}
@ -108,7 +108,7 @@ class DeploymentService
public static function randomAllocation($node)
{
$allocation = Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first();
if (!$allocation) {
if (! $allocation) {
throw new DisplayException('No available allocation could be found for the assigned node.');
}
@ -139,7 +139,7 @@ class DeploymentService
$diskLimitReached = (($totals->disk + $disk) > $limit);
}
return (!$diskLimitReached && !$memoryLimitReached);
return ! $diskLimitReached && ! $memoryLimitReached;
}
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,15 +21,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Services;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Pterodactyl\Notifications\Daemon;
class NotificationService {
class NotificationService
{
protected $server;
protected $user;
@ -53,7 +53,7 @@ class NotificationService {
public function pass(array $notification)
{
if (!$notification->type) {
if (! $notification->type) {
return;
}

View file

@ -1,7 +1,7 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Services;
use DB;
@ -28,9 +29,8 @@ use Uuid;
class UuidService
{
/**
* Constructor
* Constructor.
*/
public function __construct()
{
@ -39,28 +39,24 @@ class UuidService
/**
* Generate a unique UUID validating against specified table and column.
* Defaults to `users.uuid`
* Defaults to `users.uuid`.
*
* @param string $table
* @param string $field
* @param integer $type The type of UUID to generate.
* @param int $type The type of UUID to generate.
* @return string
*/
public function generate($table = 'users', $field = 'uuid', $type = 4)
{
$return = false;
do {
$uuid = Uuid::generate($type);
if (!DB::table($table)->where($field, $uuid)->exists()) {
if (! DB::table($table)->where($field, $uuid)->exists()) {
$return = $uuid;
}
} while (!$return);
} while (! $return);
return (string) $return;
}
/**
@ -72,21 +68,16 @@ class UuidService
*/
public function generateShort($table = 'servers', $field = 'uuidShort', $attachedUuid = null)
{
$return = false;
do {
$short = (is_null($attachedUuid)) ? substr(Uuid::generate(4), 0, 8) : substr($attachedUuid, 0, 8);
$attachedUuid = null;
if (!DB::table($table)->where($field, $short)->exists()) {
if (! DB::table($table)->where($field, $short)->exists()) {
$return = $short;
}
} while (!$return);
} while (! $return);
return (string) $return;
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Services;
use Cache;
@ -28,11 +29,10 @@ use GuzzleHttp\Client;
class VersionService
{
protected static $versions;
/**
* Constructor
* Constructor.
*/
public function __construct()
{
@ -78,7 +78,7 @@ class VersionService
return true;
}
return (version_compare(config('app.version'), self::$versions->panel) >= 0);
return version_compare(config('app.version'), self::$versions->panel) >= 0;
}
public static function isLatestDaemon($daemon)
@ -87,7 +87,6 @@ class VersionService
return true;
}
return (version_compare($daemon, self::$versions->daemon) >= 0);
return version_compare($daemon, self::$versions->daemon) >= 0;
}
}