Completed
Push — 1.x ( 5ef5a6...a03999 )
by Akihito
12s
created

HttpCache   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 26
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0
wmc 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use BEAR\QueryRepository\HttpCacheInterface as DeprecatedHttpCacheInterface;
8
use BEAR\Sunday\Extension\Transfer\HttpCacheInterface;
9
use Override;
10
11
use function http_response_code;
12
13
/** @psalm-suppress DeprecatedInterface for BC */
14 14
final readonly class HttpCache implements HttpCacheInterface, DeprecatedHttpCacheInterface
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 14 at column 6
Loading history...
15
{
16 14
    public function __construct(
17 14
        private ResourceStorageInterface $storage,
18
    ) {
19
    }
20
21
    /**
22 2
     * {@inheritDoc}
23
     */
24 2
    #[Override]
25
    public function isNotModified(array $server): bool
26
    {
27
        return isset($server[Header::HTTP_IF_NONE_MATCH]) && $this->storage->hasEtag($server[Header::HTTP_IF_NONE_MATCH]);
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     *
33
     * @return void
34
     */
35
    #[Override]
36
    public function transfer()
37
    {
38
        // @codeCoverageIgnoreStart
39
        http_response_code(304);
40
        // @codeCoverageIgnoreEnd
41
    }
42
}
43