Skip to content

Commit

Permalink
Code style fixes by php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
doobry-systemli committed Oct 26, 2022
1 parent 28ce32a commit 5bb1177
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Entity;

use App\Enum\Roles;
use App\Traits\TwofactorBackupCodeTrait;
use App\Traits\CreationTimeTrait;
use App\Traits\DeleteTrait;
use App\Traits\DomainAwareTrait;
Expand All @@ -24,6 +23,7 @@
use App\Traits\RecoverySecretBoxTrait;
use App\Traits\RecoveryStartTimeTrait;
use App\Traits\SaltTrait;
use App\Traits\TwofactorBackupCodeTrait;
use App\Traits\TwofactorTrait;
use App\Traits\UpdatedTimeTrait;
use Scheb\TwoFactorBundle\Model\BackupCodeInterface;
Expand Down Expand Up @@ -55,7 +55,7 @@ class User implements UserInterface, EncoderAwareInterface, TwoFactorInterface,
use MailCryptPublicKeyTrait;
use OpenPgpKeyTrait;
use TwofactorTrait;
use TwofactorBackupCodeTrait;
use TwofactorBackupCodeTrait;

public const CURRENT_PASSWORD_VERSION = 2;

Expand Down
68 changes: 32 additions & 36 deletions src/Traits/TwofactorBackupCodeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ trait TwofactorBackupCodeTrait
/** @var array */
private $totpBackupCodes = [];

public function getBackupCodes(): array {
return $this->totpBackupCodes;
}
public function getBackupCodes(): array
{
return $this->totpBackupCodes;
}

/**
* {@inheritdoc}
Expand All @@ -25,39 +26,34 @@ public function isBackupCode(string $code): bool
public function invalidateBackupCode(string $code): void
{
$key = array_search($code, $this->totpBackupCodes, true);
if ($key !== false) {
unset ($this->totpBackupCodes[$key]);
}
if (false !== $key) {
unset($this->totpBackupCodes[$key]);
}
}

public function clearBackupCodes(): void
{
$this->totpBackupCodes = [];
}

/**
* {@inheritdoc}
*/
public function addBackupCode(string $backupCode): void
{
if (!in_array($backupCode, $this->totpBackupCodes)) {
$this->totpBackupCodes[] = $backupCode;
}
}

/**
* @return void
*/
public function clearBackupCodes(): void
{
$this->totpBackupCodes = [];
}

/**
* {@inheritdoc}
*/
public function addBackupCode(string $backupCode): void
{
if (!in_array($backupCode, $this->totpBackupCodes)) {
$this->totpBackupCodes[] = $backupCode;
}
}

/**
* @return array
*/
public function generateBackupCodes(): array
{
$codes = [];
for ($i = 0; $i < 6; ++$i) {
$codes[] = (string) random_int(100000, 999999);
}
$this->totpBackupCodes = $codes;
return $this->totpBackupCodes;
}
public function generateBackupCodes(): array
{
$codes = [];
for ($i = 0; $i < 6; ++$i) {
$codes[] = (string) random_int(100000, 999999);
}
$this->totpBackupCodes = $codes;

return $this->totpBackupCodes;
}
}

0 comments on commit 5bb1177

Please sign in to comment.