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

HttpAttributesContainer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 59
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setStatusCode() 0 4 1
A getStatusCode() 0 4 1
A setHeader() 0 4 1
A getHeaders() 0 4 1
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
}