-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathHttpCache.php
More file actions
42 lines (35 loc) · 961 Bytes
/
HttpCache.php
File metadata and controls
42 lines (35 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace BEAR\QueryRepository;
use BEAR\QueryRepository\HttpCacheInterface as DeprecatedHttpCacheInterface;
use BEAR\Sunday\Extension\Transfer\HttpCacheInterface;
use Override;
use function http_response_code;
/** @psalm-suppress DeprecatedInterface for BC */
final readonly class HttpCache implements HttpCacheInterface, DeprecatedHttpCacheInterface
{
public function __construct(
private ResourceStorageInterface $storage,
) {
}
/**
* {@inheritDoc}
*/
#[Override]
public function isNotModified(array $server): bool
{
return isset($server[Header::HTTP_IF_NONE_MATCH]) && $this->storage->hasEtag($server[Header::HTTP_IF_NONE_MATCH]);
}
/**
* {@inheritDoc}
*
* @return void
*/
#[Override]
public function transfer()
{
// @codeCoverageIgnoreStart
http_response_code(304);
// @codeCoverageIgnoreEnd
}
}