Skip to content

Commit 2b89a79

Browse files
committed
Drop compatibility for old spomky-labs/otphp
1 parent da5e199 commit 2b89a79

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

src/google-authenticator/Security/TwoFactor/Provider/Google/GoogleTotpFactory.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@ public function createTotpForUser(TwoFactorInterface $user): TOTPInterface
3232
throw new TwoFactorProviderLogicException('Cannot initialize TOTP, no secret code provided.');
3333
}
3434

35-
// Compatibility for spomky-labs/otphp version 12
36-
if ((new ReflectionClass(TOTP::class))->hasProperty('clock')) {
37-
/** @psalm-suppress ArgumentTypeCoercion */
38-
$totp = TOTP::create($secret, 30, 'sha1', $this->digits, clock: $this->clock);
39-
} else {
40-
/** @psalm-suppress ArgumentTypeCoercion */
41-
$totp = TOTP::create($secret, 30, 'sha1', $this->digits);
42-
}
35+
$totp = TOTP::create($secret, 30, 'sha1', $this->digits, clock: $this->clock);
4336

4437
$userAndHost = $user->getGoogleAuthenticatorUsername().(null !== $this->server && $this->server ? '@'.$this->server : '');
4538
$totp->setLabel($userAndHost);

src/totp/Security/TwoFactor/Provider/Totp/TotpFactory.php

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,13 @@ public function createTotpForUser(TwoFactorInterface $user): TOTPInterface
4040
throw new TwoFactorProviderLogicException('Cannot initialize TOTP, no secret code provided.');
4141
}
4242

43-
// Compatibility for spomky-labs/otphp version 12
44-
if ((new ReflectionClass(TOTP::class))->hasProperty('clock')) {
45-
/** @psalm-suppress ArgumentTypeCoercion */
46-
$totp = TOTP::create(
47-
$secret,
48-
$totpConfiguration->getPeriod(),
49-
$totpConfiguration->getAlgorithm(),
50-
$totpConfiguration->getDigits(),
51-
clock: $this->clock,
52-
);
53-
} else {
54-
/** @psalm-suppress ArgumentTypeCoercion */
55-
$totp = TOTP::create(
56-
$secret,
57-
$totpConfiguration->getPeriod(),
58-
$totpConfiguration->getAlgorithm(),
59-
$totpConfiguration->getDigits(),
60-
);
61-
}
43+
$totp = TOTP::create(
44+
$secret,
45+
$totpConfiguration->getPeriod(),
46+
$totpConfiguration->getAlgorithm(),
47+
$totpConfiguration->getDigits(),
48+
clock: $this->clock,
49+
);
6250

6351
$userAndHost = $user->getTotpAuthenticationUsername().(null !== $this->server && $this->server ? '@'.$this->server : '');
6452
$totp->setLabel($userAndHost);

0 commit comments

Comments
 (0)