Use more standardized phpcs

This commit is contained in:
Dane Everitt 2021-01-23 12:33:34 -08:00
parent a043071e3c
commit c449ca5155
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
493 changed files with 1116 additions and 3903 deletions

View file

@ -41,12 +41,6 @@ class ToggleTwoFactorService
/**
* ToggleTwoFactorService constructor.
*
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @param \PragmaRX\Google2FA\Google2FA $google2FA
* @param \Pterodactyl\Repositories\Eloquent\RecoveryTokenRepository $recoveryTokenRepository
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(
ConnectionInterface $connection,
@ -65,9 +59,6 @@ class ToggleTwoFactorService
/**
* Toggle 2FA on an account only if the token provided is valid.
*
* @param \Pterodactyl\Models\User $user
* @param string $token
* @param bool|null $toggleState
* @return string[]
*
* @throws \Throwable
@ -82,7 +73,7 @@ class ToggleTwoFactorService
$isValidToken = $this->google2FA->verifyKey($secret, $token, config()->get('pterodactyl.auth.2fa.window'));
if (! $isValidToken) {
if (!$isValidToken) {
throw new TwoFactorAuthenticationTokenInvalid('The token provided is not valid.');
}
@ -95,9 +86,9 @@ class ToggleTwoFactorService
// which will then be marked as deleted from the database and will also bypass 2FA protections
// on their account.
$tokens = [];
if ((! $toggleState && ! $user->use_totp) || $toggleState) {
if ((!$toggleState && !$user->use_totp) || $toggleState) {
$inserts = [];
for ($i = 0; $i < 10; $i++) {
for ($i = 0; $i < 10; ++$i) {
$token = Str::random(10);
$inserts[] = [
@ -118,7 +109,7 @@ class ToggleTwoFactorService
$this->repository->withoutFreshModel()->update($user->id, [
'totp_authenticated_at' => Carbon::now(),
'use_totp' => (is_null($toggleState) ? ! $user->use_totp : $toggleState),
'use_totp' => (is_null($toggleState) ? !$user->use_totp : $toggleState),
]);
return $tokens;

View file

@ -11,7 +11,7 @@ use Illuminate\Contracts\Config\Repository as ConfigRepository;
class TwoFactorSetupService
{
const VALID_BASE32_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
public const VALID_BASE32_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
/**
* @var \Illuminate\Contracts\Config\Repository
@ -30,10 +30,6 @@ class TwoFactorSetupService
/**
* TwoFactorSetupService constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(
ConfigRepository $config,
@ -50,9 +46,6 @@ class TwoFactorSetupService
* QR code URL. This URL will need to be attached to a QR generating service in
* order to function.
*
* @param \Pterodactyl\Models\User $user
* @return string
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -60,7 +53,7 @@ class TwoFactorSetupService
{
$secret = '';
try {
for ($i = 0; $i < $this->config->get('pterodactyl.auth.2fa.bytes', 16); $i++) {
for ($i = 0; $i < $this->config->get('pterodactyl.auth.2fa.bytes', 16); ++$i) {
$secret .= substr(self::VALID_BASE32_CHARACTERS, random_int(0, 31), 1);
}
} catch (Exception $exception) {

View file

@ -33,11 +33,6 @@ class UserCreationService
/**
* CreationService constructor.
*
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwordBroker
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(
ConnectionInterface $connection,
@ -54,7 +49,6 @@ class UserCreationService
/**
* Create a new user on the system.
*
* @param array $data
* @return \Pterodactyl\Models\User
*
* @throws \Exception
@ -62,12 +56,12 @@ class UserCreationService
*/
public function handle(array $data)
{
if (array_key_exists('password', $data) && ! empty($data['password'])) {
if (array_key_exists('password', $data) && !empty($data['password'])) {
$data['password'] = $this->hasher->make($data['password']);
}
$this->connection->beginTransaction();
if (! isset($data['password']) || empty($data['password'])) {
if (!isset($data['password']) || empty($data['password'])) {
$generateResetToken = true;
$data['password'] = $this->hasher->make(str_random(30));
}

View file

@ -34,10 +34,6 @@ class UserDeletionService
/**
* DeletionService constructor.
*
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
* @param \Illuminate\Contracts\Translation\Translator $translator
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(
ServerRepositoryInterface $serverRepository,
@ -53,6 +49,7 @@ class UserDeletionService
* Delete a user from the panel only if they have no servers attached to their account.
*
* @param int|\Pterodactyl\Models\User $user
*
* @return bool|null
*
* @throws \Pterodactyl\Exceptions\DisplayException

View file

@ -23,9 +23,6 @@ class UserUpdateService
/**
* UpdateService constructor.
*
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
* @param \Pterodactyl\Repositories\Eloquent\UserRepository $repository
*/
public function __construct(Hasher $hasher, UserRepository $repository)
{
@ -36,8 +33,6 @@ class UserUpdateService
/**
* Update the user model instance.
*
* @param \Pterodactyl\Models\User $user
* @param array $data
* @return \Pterodactyl\Models\User
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -45,7 +40,7 @@ class UserUpdateService
*/
public function handle(User $user, array $data)
{
if (! empty(array_get($data, 'password'))) {
if (!empty(array_get($data, 'password'))) {
$data['password'] = $this->hasher->make($data['password']);
} else {
unset($data['password']);