Skip to content

Commit

Permalink
refactor helper test w/ new interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed Jun 6, 2024
1 parent f155b6d commit a7630f4
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 117 deletions.
2 changes: 1 addition & 1 deletion src/Generator/ResetPasswordTokenGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @internal
*/
final class ResetPasswordTokenGenerator
final class ResetPasswordTokenGenerator implements ResetPasswordTokenGeneratorInterface
{
/**
* @param string $signingKey Unique, random, cryptographically secure string
Expand Down
20 changes: 20 additions & 0 deletions src/Generator/ResetPasswordTokenGeneratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the SymfonyCasts ResetPasswordBundle package.
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SymfonyCasts\Bundle\ResetPassword\Generator;

use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordTokenComponents;

/**
* @author Jesse Rushlow <[email protected]>
*/
interface ResetPasswordTokenGeneratorInterface
{
public function createToken(\DateTimeInterface $expiresAt, int|string $userId, ?string $verifier = null): ResetPasswordTokenComponents;
}
8 changes: 4 additions & 4 deletions src/ResetPasswordHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
use SymfonyCasts\Bundle\ResetPassword\Exception\ExpiredResetPasswordTokenException;
use SymfonyCasts\Bundle\ResetPassword\Exception\InvalidResetPasswordTokenException;
use SymfonyCasts\Bundle\ResetPassword\Exception\TooManyPasswordRequestsException;
use SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordTokenGenerator;
use SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordTokenGeneratorInterface;
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestInterface;
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordToken;
use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface;
use SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleaner;
use SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleanerInterface;

/**
* @author Jesse Rushlow <[email protected]>
Expand All @@ -34,8 +34,8 @@ final class ResetPasswordHelper implements ResetPasswordHelperInterface
* @param int $requestThrottleTime Another password reset cannot be made faster than this throttle time in seconds
*/
public function __construct(
private ResetPasswordTokenGenerator $generator,
private ResetPasswordCleaner $cleaner,
private ResetPasswordTokenGeneratorInterface $generator,
private ResetPasswordCleanerInterface $cleaner,
private ResetPasswordRequestRepositoryInterface $repository,
private int $resetRequestLifetime,
private int $requestThrottleTime,
Expand Down
2 changes: 1 addition & 1 deletion src/Util/ResetPasswordCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @final
*/
class ResetPasswordCleaner
class ResetPasswordCleaner implements ResetPasswordCleanerInterface
{
/**
* @param bool $enabled Enable/disable garbage collection
Expand Down
18 changes: 18 additions & 0 deletions src/Util/ResetPasswordCleanerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the SymfonyCasts ResetPasswordBundle package.
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SymfonyCasts\Bundle\ResetPassword\Util;

/**
* @author Jesse Rushlow <[email protected]>
*/
interface ResetPasswordCleanerInterface
{
public function handleGarbageCollection(bool $force = false): int;
}
Loading

0 comments on commit a7630f4

Please sign in to comment.