Completed
Push — master ( 135c70...3db5e8 )
by
unknown
18:19
created

Header::sendStripQueryParameterHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
namespace Aoe\Varnish\System;
3
4
use Aoe\Varnish\Domain\Model\TagInterface;
5
6
class Header
7
{
8
    /**
9
     * @var string
10
     */
11
    const HEADER_TAGS = 'X-Tags: %s';
12
13
    /**
14
     * @var string
15
     */
16
    const HEADER_DEBUG = 'X-Debug: 1';
17
18
    /**
19
     * @var string
20
     */
21
    const HEADER_ENABLED = 'X-Varnish-enabled: 1';
22
23
    /**
24
     * @var string
25
     */
26
    const HEADER_STRIP_QUERY_PARAMETER = 'X-Varnish-Strip-Query-Parameter: 1';
27 1
28
    /**
29 1
     * @param TagInterface $tag
30 1
     * @return void
31
     */
32
    public function sendHeaderForTag(TagInterface $tag)
33
    {
34
        if (false === $tag->isValid()) {
35
            throw new \RuntimeException('Tag is not valid', 1435047447);
36
        }
37
        header(sprintf(self::HEADER_TAGS, $tag->getIdentifier()), false);
38
    }
39
40
    /**
41
     * @return void
42
     */
43
    public function sendDebugHeader()
44
    {
45
        header(self::HEADER_DEBUG);
46
    }
47
48
    /**
49
     * @return void
50
     */
51
    public function sendEnabledHeader()
52
    {
53
        header(self::HEADER_ENABLED);
54
    }
55
56
    /**
57
     * @return void
58
     */
59
    public function sendStripQueryParameterHeader()
60
    {
61
        header(self::HEADER_STRIP_QUERY_PARAMETER);
62
    }
63
}
64