Completed
Push — master ( 8b149d...d0a098 )
by Kevin
07:29
created

Header   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 27.27%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 45
rs 10
ccs 3
cts 11
cp 0.2727

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sendDebugHeader() 0 4 1
A sendEnabledHeader() 0 4 1
A sendHeaderForTag() 0 7 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
     * @param TagInterface $tag
25
     * @return void
26
     */
27 1
    public function sendHeaderForTag(TagInterface $tag)
28
    {
29 1
        if (false === $tag->isValid()) {
30
            throw new \RuntimeException('Tag is not valid', 1435047447);
31
        }
32 1
        header(sprintf(self::HEADER_TAGS, $tag->getIdentifier()), false);
33
    }
34
35
    /**
36
     * @return void
37
     */
38
    public function sendDebugHeader()
39
    {
40
        header(self::HEADER_DEBUG);
41
    }
42
43
    /**
44
     * @return void
45
     */
46
    public function sendEnabledHeader()
47
    {
48
        header(self::HEADER_ENABLED);
49
    }
50
}
51