Apply fixes from StyleCI
This commit is contained in:
parent
a1d3bbf73d
commit
c1fb0a665f
150 changed files with 1558 additions and 1760 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue