Headers::direct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace mQueue\Controller\ActionHelper;
4
5
use Zend_Controller_Action_Helper_Abstract;
6
7
class Headers extends Zend_Controller_Action_Helper_Abstract
8
{
9
    /**
10
     * Set appropriate headers according to content type
11
     *
12
     * @param mixed $contentType
13
     */
14 3
    public function headers($contentType): void
15
    {
16 3
        $response = $this->getActionController()->getResponse();
17 3
        $response->setHeader('Content-Type', $contentType);
18 3
        $response->setHeader('Cache-Control', 'max-age=604800');
19
20
        // This check is required when running via unit tests
21 3
        if (headers_sent()) {
22 3
            return;
23
        }
24
25
        header_remove('Pragma');
26
        header_remove('Expires');
27
    }
28
29
    /**
30
     * Strategy pattern: call helper as broker method
31
     *
32
     * @param mixed $data
33
     */
34 3
    public function direct($data): void
35
    {
36 3
        $this->headers($data);
37 3
    }
38
}
39