Passed
Push — master ( afdc6b...e39cc4 )
by Adrien
03:24
created

Headers::direct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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
    public function headers($contentType): void
15
    {
16
        $response = $this->getActionController()->getResponse();
17
        $response->setHeader('Content-Type', $contentType);
18
        $response->setHeader('Cache-Control', 'max-age=604800');
19
20
        // This check is required when running via unit tests
21
        if (headers_sent()) {
22
            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
    public function direct($data)
35
    {
36
        return $this->headers($data);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->headers($data) targeting mQueue\Controller\ActionHelper\Headers::headers() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
    }
38
}
39