@@ -84,15 +84,7 @@ public function shouldReport(\Throwable $throwable): bool
8484 */
8585 private function shouldntReport (\Throwable $ throwable ): bool
8686 {
87- if ($ this ->shouldSkip ($ throwable )) {
88- return true ;
89- }
90-
91- return !$ this ->attempt (
92- $ this ->fingerprintFor ($ throwable ),
93- config ('exception-notify.rate_limit.max_attempts ' ),
94- config ('exception-notify.rate_limit.decay_seconds ' )
95- );
87+ return $ this ->shouldSkip ($ throwable ) ? true : !$ this ->attempt ($ throwable );
9688 }
9789
9890 private function shouldSkip (\Throwable $ throwable ): bool
@@ -107,25 +99,29 @@ private function shouldSkip(\Throwable $throwable): bool
10799 }
108100
109101 /**
110- * @see \Illuminate\Foundation\Exceptions\Handler::shouldntReport()
111- * @see \Illuminate\Foundation\Exceptions\Handler::throttle()
112- * @see \Illuminate\Foundation\Exceptions\Handler::throttleUsing()
102+ * @see RateLimiter::attempt()
103+ * @see \Illuminate\Cache\RateLimiting\Limit
113104 */
114- private function fingerprintFor (\Throwable $ throwable ): string
105+ private function attempt (\Throwable $ throwable ): bool
115106 {
116- return config ('exception-notify.rate_limit.key_prefix ' ).hash (
117- 'xxh128 ' ,
118- implode (': ' , [$ throwable ->getFile (), $ throwable ->getLine (), $ throwable ->getCode ()])
107+ return with (new RateLimiter (Cache::store (config ('exception-notify.rate_limiter.cache_store ' ))))->attempt (
108+ $ this ->fingerprintFor ($ throwable ),
109+ config ('exception-notify.rate_limiter.max_attempts ' ),
110+ static fn (): bool => true ,
111+ config ('exception-notify.rate_limiter.decay_seconds ' )
119112 );
120113 }
121114
122115 /**
123- * @see RateLimiter::attempt
116+ * @see \Illuminate\Foundation\Exceptions\Handler::shouldntReport()
117+ * @see \Illuminate\Foundation\Exceptions\Handler::throttle()
118+ * @see \Illuminate\Foundation\Exceptions\Handler::throttleUsing()
124119 */
125- private function attempt ( string $ key , int $ maxAttempts , int $ decaySeconds = 60 ): bool
120+ private function fingerprintFor ( \ Throwable $ throwable ): string
126121 {
127- return (
128- new RateLimiter (Cache::store (config ('exception-notify.rate_limit.cache_store ' , config ('cache.default ' ))))
129- )->attempt ($ key , $ maxAttempts , static fn (): bool => true , $ decaySeconds );
122+ return config ('exception-notify.rate_limiter.key_prefix ' ).hash (
123+ 'sha256 ' ,
124+ implode (': ' , [$ throwable ->getFile (), $ throwable ->getLine (), $ throwable ->getCode ()])
125+ );
130126 }
131127}
0 commit comments