Skip to content

Commit a7630f4

Browse files
committed
refactor helper test w/ new interfaces
1 parent f155b6d commit a7630f4

6 files changed

+210
-117
lines changed

src/Generator/ResetPasswordTokenGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @internal
2020
*/
21-
final class ResetPasswordTokenGenerator
21+
final class ResetPasswordTokenGenerator implements ResetPasswordTokenGeneratorInterface
2222
{
2323
/**
2424
* @param string $signingKey Unique, random, cryptographically secure string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the SymfonyCasts ResetPasswordBundle package.
5+
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
namespace SymfonyCasts\Bundle\ResetPassword\Generator;
11+
12+
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordTokenComponents;
13+
14+
/**
15+
* @author Jesse Rushlow <[email protected]>
16+
*/
17+
interface ResetPasswordTokenGeneratorInterface
18+
{
19+
public function createToken(\DateTimeInterface $expiresAt, int|string $userId, ?string $verifier = null): ResetPasswordTokenComponents;
20+
}

src/ResetPasswordHelper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
use SymfonyCasts\Bundle\ResetPassword\Exception\ExpiredResetPasswordTokenException;
1313
use SymfonyCasts\Bundle\ResetPassword\Exception\InvalidResetPasswordTokenException;
1414
use SymfonyCasts\Bundle\ResetPassword\Exception\TooManyPasswordRequestsException;
15-
use SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordTokenGenerator;
15+
use SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordTokenGeneratorInterface;
1616
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestInterface;
1717
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordToken;
1818
use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface;
19-
use SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleaner;
19+
use SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleanerInterface;
2020

2121
/**
2222
* @author Jesse Rushlow <[email protected]>
@@ -34,8 +34,8 @@ final class ResetPasswordHelper implements ResetPasswordHelperInterface
3434
* @param int $requestThrottleTime Another password reset cannot be made faster than this throttle time in seconds
3535
*/
3636
public function __construct(
37-
private ResetPasswordTokenGenerator $generator,
38-
private ResetPasswordCleaner $cleaner,
37+
private ResetPasswordTokenGeneratorInterface $generator,
38+
private ResetPasswordCleanerInterface $cleaner,
3939
private ResetPasswordRequestRepositoryInterface $repository,
4040
private int $resetRequestLifetime,
4141
private int $requestThrottleTime,

src/Util/ResetPasswordCleaner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
* @final
2121
*/
22-
class ResetPasswordCleaner
22+
class ResetPasswordCleaner implements ResetPasswordCleanerInterface
2323
{
2424
/**
2525
* @param bool $enabled Enable/disable garbage collection
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the SymfonyCasts ResetPasswordBundle package.
5+
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
namespace SymfonyCasts\Bundle\ResetPassword\Util;
11+
12+
/**
13+
* @author Jesse Rushlow <[email protected]>
14+
*/
15+
interface ResetPasswordCleanerInterface
16+
{
17+
public function handleGarbageCollection(bool $force = false): int;
18+
}

0 commit comments

Comments
 (0)