Completed
Push — 1.x ( 82effb...ab39dc )
by Akihito
19s
created

HttpCacheWeb::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file is part of the BEAR.QueryRepository package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\QueryRepository;
8
9
final class HttpCacheWeb implements HttpCacheInterface
10
{
11
    /**
12
     * @var ResourceStorageInterface
13
     */
14
    private $storage;
15
16 13
    public function __construct(ResourceStorageInterface $storage)
17
    {
18 13
        $this->storage = $storage;
19 13
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function isNotModified(array $server) : bool
25
    {
26 2
        return isset($server['HTTP_IF_NONE_MATCH']) && $this->storage->hasEtag($server['HTTP_IF_NONE_MATCH']);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function transfer()
33
    {
34
        \http_response_code(304);
35
    }
36
}
37