Skip to content

Commit 17fb0fe

Browse files
[RateLimiter] Add RateLimiterFactoryInterface
1 parent bec056a commit 17fb0fe

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.3
5+
---
6+
7+
* Add `RateLimiterFactoryInterface` as an alias of the `limiter` service
8+
49
7.2
510
---
611

src/Symfony/Bundle/FrameworkBundle/Resources/config/rate_limiter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

1414
use Symfony\Component\RateLimiter\RateLimiterFactory;
15+
use Symfony\Component\RateLimiter\RateLimiterFactoryInterface;
1516

1617
return static function (ContainerConfigurator $container) {
1718
$container->services()
@@ -26,5 +27,7 @@
2627
abstract_arg('storage'),
2728
null,
2829
])
30+
31+
->alias(RateLimiterFactoryInterface::class, 'limiter')
2932
;
3033
};

src/Symfony/Component/RateLimiter/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.3
5+
---
6+
7+
* Add `RateLimiterFactoryInterface`
8+
49
6.4
510
---
611

src/Symfony/Component/RateLimiter/RateLimiterFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* @author Wouter de Jong <wouter@wouterj.nl>
2626
*/
27-
final class RateLimiterFactory
27+
final class RateLimiterFactory implements RateLimiterFactoryInterface
2828
{
2929
private array $config;
3030

@@ -53,15 +53,15 @@ public function create(?string $key = null): LimiterInterface
5353
};
5454
}
5555

56-
protected static function configureOptions(OptionsResolver $options): void
56+
private static function configureOptions(OptionsResolver $options): void
5757
{
5858
$intervalNormalizer = static function (Options $options, string $interval): \DateInterval {
5959
// Create DateTimeImmutable from unix timesatmp, so the default timezone is ignored and we don't need to
6060
// deal with quirks happening when modifying dates using a timezone with DST.
6161
$now = \DateTimeImmutable::createFromFormat('U', time());
6262

6363
try {
64-
$nowPlusInterval = @$now->modify('+' . $interval);
64+
$nowPlusInterval = @$now->modify('+'.$interval);
6565
} catch (\DateMalformedStringException $e) {
6666
throw new \LogicException(\sprintf('Cannot parse interval "%s", please use a valid unit as described on https://www.php.net/datetime.formats.relative.', $interval), 0, $e);
6767
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\RateLimiter;
13+
14+
/**
15+
* @author Alexandre Daubois <alex.daubois@gmail.com>
16+
*/
17+
interface RateLimiterFactoryInterface
18+
{
19+
/**
20+
* @param string|null $key an optional key used to identify the limiter
21+
*/
22+
public function create(?string $key = null): LimiterInterface;
23+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy