Skip to content

Commit

Permalink
Merge branch 'master' of github.com:spatie/laravel-responsecache
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Apr 27, 2021
2 parents 9fd638c + bf66dd9 commit 3bf314f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/CacheItemSelector/AbstractRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function withCookies(array $cookies): self
public function withHeaders(array $headers): self
{
$this->server = collect($this->server)
->filter(fn(string $val, string $key) => !str_starts_with($key, 'HTTP_'))
->filter(fn (string $val, string $key) => ! str_starts_with($key, 'HTTP_'))
->merge(collect($headers)
->mapWithKeys(function (string $val, string $key) {
return ['HTTP_' . str_replace('-', '_', Str::upper($key)) => $val];
Expand Down Expand Up @@ -92,7 +92,7 @@ protected function build(string $uri): Request

if (isset($this->cacheNameSuffix)) {
$request->attributes->add([
'responsecache.cacheNameSuffix' => $this->cacheNameSuffix
'responsecache.cacheNameSuffix' => $this->cacheNameSuffix,
]);
}

Expand Down
11 changes: 5 additions & 6 deletions src/CacheItemSelector/CacheItemSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ class CacheItemSelector extends AbstractRequestBuilder
public function __construct(
protected RequestHasher $hasher,
protected ResponseCacheRepository $cache,
)
{
) {
}

public function usingTags(string|array $tags): static
public function usingTags(string | array $tags): static
{
$this->tags = is_array($tags) ? $tags : func_get_args();

return $this;
}

public function forUrls(string|array $urls): static
public function forUrls(string | array $urls): static
{
$this->urls = is_array($urls) ? $urls : func_get_args();

Expand All @@ -40,8 +39,8 @@ public function forget(): void

return $this->hasher->getHashFor($request);
})
->filter(fn($hash) => $this->taggedCache($this->tags)->has($hash))
->each(fn($hash) => $this->taggedCache($this->tags)->forget($hash));
->filter(fn ($hash) => $this->taggedCache($this->tags)->has($hash))
->each(fn ($hash) => $this->taggedCache($this->tags)->forget($hash));
}

protected function taggedCache(array $tags = []): ResponseCacheRepository
Expand Down

0 comments on commit 3bf314f

Please sign in to comment.