+ *
+ * @experimental in 5.2
+ */
+final class Window implements LimiterStateInterface
+{
+ private $id;
+ private $hitCount = 0;
+ private $intervalInSeconds;
+
+ public function __construct(string $id, int $intervalInSeconds)
+ {
+ $this->id = $id;
+ $this->intervalInSeconds = $intervalInSeconds;
+ }
+
+ public function getId(): string
+ {
+ return $this->id;
+ }
+
+ public function getExpirationTime(): ?int
+ {
+ return $this->intervalInSeconds;
+ }
+
+ public function add(int $hits = 1)
+ {
+ $this->hitCount += $hits;
+ }
+
+ public function getHitCount(): int
+ {
+ return $this->hitCount;
+ }
+
+ public function serialize(): string
+ {
+ // $intervalInSeconds is not serialized, it should only be set
+ // upon first creation of the Window.
+ return serialize([$this->id, $this->hitCount]);
+ }
+
+ public function unserialize($serialized): void
+ {
+ [$this->id, $this->hitCount] = unserialize($serialized);
+ }
+}
diff --git a/src/Symfony/Component/RateLimiter/composer.json b/src/Symfony/Component/RateLimiter/composer.json
new file mode 100644
index 0000000000000..92e89c517a9fc
--- /dev/null
+++ b/src/Symfony/Component/RateLimiter/composer.json
@@ -0,0 +1,38 @@
+{
+ "name": "symfony/rate-limiter",
+ "type": "library",
+ "description": "Symfony Rate Limiter Component",
+ "keywords": ["limiter", "rate-limiter"],
+ "homepage": "https://symfony.com",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Wouter de Jong",
+ "email": "wouter@wouterj.nl"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "require": {
+ "php": ">=7.2.5",
+ "symfony/lock": "^5.2",
+ "symfony/options-resolver": "^5.1"
+ },
+ "require-dev": {
+ "psr/cache": "^1.0"
+ },
+ "autoload": {
+ "psr-4": { "Symfony\\Component\\RateLimiter\\": "" },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "minimum-stability": "dev",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "5.2-dev"
+ }
+ }
+}
diff --git a/src/Symfony/Component/RateLimiter/phpunit.xml.dist b/src/Symfony/Component/RateLimiter/phpunit.xml.dist
new file mode 100644
index 0000000000000..1afd852227fb2
--- /dev/null
+++ b/src/Symfony/Component/RateLimiter/phpunit.xml.dist
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+ ./Tests/
+
+
+
+
+
+ ./
+
+ ./Tests
+ ./vendor
+
+
+
+
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