Skip to content

Commit 2e66130

Browse files
Nyholmchalasr
authored andcommitted
[RateLimiter] Rename RateLimiter to RateLimiterFactory
1 parent c608e1d commit 2e66130

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

RateLimiter/DefaultLoginRateLimiter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\HttpFoundation\RateLimiter\AbstractRequestRateLimiter;
1515
use Symfony\Component\HttpFoundation\Request;
16-
use Symfony\Component\RateLimiter\RateLimiter;
16+
use Symfony\Component\RateLimiter\RateLimiterFactory;
1717
use Symfony\Component\Security\Core\Security;
1818

1919
/**
@@ -28,20 +28,20 @@
2828
*/
2929
final class DefaultLoginRateLimiter extends AbstractRequestRateLimiter
3030
{
31-
private $globalLimiter;
32-
private $localLimiter;
31+
private $globalFactory;
32+
private $localFactory;
3333

34-
public function __construct(RateLimiter $globalLimiter, RateLimiter $localLimiter)
34+
public function __construct(RateLimiterFactory $globalFactory, RateLimiterFactory $localFactory)
3535
{
36-
$this->globalLimiter = $globalLimiter;
37-
$this->localLimiter = $localLimiter;
36+
$this->globalFactory = $globalFactory;
37+
$this->localFactory = $localFactory;
3838
}
3939

4040
protected function getLimiters(Request $request): array
4141
{
4242
return [
43-
$this->globalLimiter->create($request->getClientIp()),
44-
$this->localLimiter->create($request->attributes->get(Security::LAST_USERNAME).$request->getClientIp()),
43+
$this->globalFactory->create($request->getClientIp()),
44+
$this->localFactory->create($request->attributes->get(Security::LAST_USERNAME).$request->getClientIp()),
4545
];
4646
}
4747
}

Tests/EventListener/LoginThrottlingListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\RequestStack;
17-
use Symfony\Component\RateLimiter\RateLimiter;
17+
use Symfony\Component\RateLimiter\RateLimiterFactory;
1818
use Symfony\Component\RateLimiter\Storage\InMemoryStorage;
1919
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2020
use Symfony\Component\Security\Core\Exception\TooManyLoginAttemptsAuthenticationException;
@@ -35,13 +35,13 @@ protected function setUp(): void
3535
{
3636
$this->requestStack = new RequestStack();
3737

38-
$localLimiter = new RateLimiter([
38+
$localLimiter = new RateLimiterFactory([
3939
'id' => 'login',
4040
'strategy' => 'fixed_window',
4141
'limit' => 3,
4242
'interval' => '1 minute',
4343
], new InMemoryStorage());
44-
$globalLimiter = new RateLimiter([
44+
$globalLimiter = new RateLimiterFactory([
4545
'id' => 'login',
4646
'strategy' => 'fixed_window',
4747
'limit' => 6,

0 commit comments

Comments
 (0)