From 952be1c2c98de93fc4a3d12f1c39c9723d725910 Mon Sep 17 00:00:00 2001 From: Craig Anderson Date: Mon, 22 Feb 2021 15:46:37 -0500 Subject: [PATCH 1/3] Add minute argument to perMinute method for RateLimiting This PR allows the `perMinute` method accept an optional argument to specify the number of decay minutes. This allows the `perMinute` method to function in the same way that the `perHour` and `perDay` methods function. --- src/Illuminate/Cache/RateLimiting/Limit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Cache/RateLimiting/Limit.php b/src/Illuminate/Cache/RateLimiting/Limit.php index ab3463f51830..ce0c924aa98f 100644 --- a/src/Illuminate/Cache/RateLimiting/Limit.php +++ b/src/Illuminate/Cache/RateLimiting/Limit.php @@ -53,9 +53,9 @@ public function __construct($key = '', int $maxAttempts = 60, int $decayMinutes * @param int $maxAttempts * @return static */ - public static function perMinute($maxAttempts) + public static function perMinute($maxAttempts, $decayMinutes = 1) { - return new static('', $maxAttempts); + return new static('', $maxAttempts, $decayMinutes); } /** From 07a5f8af69f2af89eb8020dee3715bfc94509bcf Mon Sep 17 00:00:00 2001 From: Craig Anderson Date: Tue, 23 Feb 2021 09:50:10 -0500 Subject: [PATCH 2/3] Update phpdoc --- src/Illuminate/Cache/RateLimiting/Limit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Cache/RateLimiting/Limit.php b/src/Illuminate/Cache/RateLimiting/Limit.php index ce0c924aa98f..56f3f6c80f47 100644 --- a/src/Illuminate/Cache/RateLimiting/Limit.php +++ b/src/Illuminate/Cache/RateLimiting/Limit.php @@ -51,6 +51,7 @@ public function __construct($key = '', int $maxAttempts = 60, int $decayMinutes * Create a new rate limit. * * @param int $maxAttempts + * @param int $decayMinutes * @return static */ public static function perMinute($maxAttempts, $decayMinutes = 1) From e83d250e262fcfcb228d707cfb41126530a09f3a Mon Sep 17 00:00:00 2001 From: Craig Anderson Date: Wed, 24 Feb 2021 12:05:26 -0500 Subject: [PATCH 3/3] Create new rate limit method perMinutes --- src/Illuminate/Cache/RateLimiting/Limit.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Cache/RateLimiting/Limit.php b/src/Illuminate/Cache/RateLimiting/Limit.php index 56f3f6c80f47..3e8956cad2ad 100644 --- a/src/Illuminate/Cache/RateLimiting/Limit.php +++ b/src/Illuminate/Cache/RateLimiting/Limit.php @@ -51,10 +51,21 @@ public function __construct($key = '', int $maxAttempts = 60, int $decayMinutes * Create a new rate limit. * * @param int $maxAttempts + * @return static + */ + public static function perMinute($maxAttempts) + { + return new static('', $maxAttempts); + } + + /** + * Create a new rate limit using minutes as decay time. + * + * @param int $maxAttempts * @param int $decayMinutes * @return static */ - public static function perMinute($maxAttempts, $decayMinutes = 1) + public static function perMinutes($maxAttempts, $decayMinutes = 1) { return new static('', $maxAttempts, $decayMinutes); }