Passed
Push — master ( 59e178...7dbd33 )
by Michael
02:26
created

HttpAttributesContainer::setStatusCode()   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 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Bundle\JsonApiBundle\Response\Behaviour;
5
6
trait HttpAttributesContainer
7
{
8
    /**
9
     * Status code
10
     *
11
     * @var int
12
     */
13
    protected $statusCode = 200;
14
15
    /**
16
     * Response headers
17
     *
18
     * @var array
19
     */
20
    protected $headers = [];
21
22
    /**
23
     * Set status code
24
     *
25
     * @param  int $code
26
     * @return mixed
27
     */
28
    public function setStatusCode(int $code)
29
    {
30
        $this->statusCode = $code;
31
    }
32
33
    /**
34
     * Get status code
35
     *
36
     * @return int
37
     */
38 3
    public function getStatusCode(): int
39
    {
40 3
        return $this->statusCode;
41
    }
42
43
    /**
44
     * Set header
45
     *
46
     * @param  string $name
47
     * @param  string $value
48
     * @return mixed
49
     */
50
    public function setHeader(string $name, string $value)
51
    {
52
        $this->headers[$name] = $value;
53
    }
54
55
    /**
56
     * Get response headers
57
     *
58
     * @return array
59
     */
60 3
    public function getHeaders(): array
61
    {
62 3
        return $this->headers;
63
    }
64
}