Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Exceptions/RateLimitReachedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RateLimitReachedException extends SaloonException
/**
* Constructor
*/
public function __construct(readonly protected Limit $limit)
public function __construct(protected readonly Limit $limit)
{
parent::__construct(sprintf('Request Rate Limit Reached (Name: %s)', $this->limit->getName()));
}
Expand Down
8 changes: 7 additions & 1 deletion src/Limit.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,13 @@ public function save(RateLimitStore $store, int $resetHits = 1): static
// reset the limit completely and hit once.

if ($this->getRemainingSeconds() < 1) {
$this->resetLimit()->hit($resetHits);
// When using the fromResponse limiter, we don't need to update the hit
// as we only update the hit when the detect the too many attempts
if ($this->usesResponse()) {
$this->resetLimit();
} else {
$this->resetLimit()->hit($resetHits);
}
}

$data = [
Expand Down
2 changes: 1 addition & 1 deletion src/Stores/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FileStore implements RateLimitStore
* @throws \Saloon\Exceptions\DirectoryNotFoundException
* @throws \Saloon\Exceptions\UnableToCreateDirectoryException
*/
public function __construct(readonly protected string $directory)
public function __construct(protected readonly string $directory)
{
$this->storage = new Storage($this->directory, false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Stores/PsrStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PsrStore implements RateLimitStore
/**
* Constructor
*/
public function __construct(readonly protected CacheInterface $cache)
public function __construct(protected readonly CacheInterface $cache)
{
//
}
Expand Down
2 changes: 1 addition & 1 deletion src/Stores/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RedisStore implements RateLimitStore
/**
* Constructor
*/
public function __construct(readonly protected Redis $redis)
public function __construct(protected readonly Redis $redis)
{
//
}
Expand Down