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

HttpCacheWeb   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 28
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isNotModified() 0 4 2
A transfer() 0 4 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