Completed
Pull Request — master (#69)
by
unknown
01:51
created

Response::headers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Fractal;
4
5
class Response
6
{
7
    /** @var int */
8
    protected $statusCode = 200;
9
10
    /** @var array */
11
    protected $headers = [];
12
13
    /**
14
     * Get the status code.
15
     *
16
     * @return int
17
     */
18
    public function statusCode()
19
    {
20
        return $this->statusCode;
21
    }
22
23
    /**
24
     * Set the status code.
25
     *
26
     * @param  int $statusCode
27
     *
28
     * @return self
29
     */
30
    public function code($statusCode)
31
    {
32
        $this->statusCode = $statusCode;
33
34
        return $this;
35
    }
36
37
    /**
38
     * Return HTTP headers.
39
     *
40
     * @return array
41
     */
42
    public function getHeaders()
43
    {
44
        return $this->headers;
45
    }
46
47
    /**
48
     * Set one HTTP header.
49
     *
50
     * @param  string $key
51
     * @param  string $value
52
     *
53
     * @return self
54
     */
55
    public function header($key, $value)
56
    {
57
        $this->headers[$key] = $value;
58
59
        return $this;
60
    }
61
62
    /**
63
     * Set multiple headers at once.
64
     *
65
     * @param  array $headers
66
     *
67
     * @return self
68
     */
69
    public function headers($headers)
70
    {
71
        foreach ($headers as $key => $value) {
72
            $this->header($key, $value);
73
        }
74
75
        return $this;
76
    }
77
}
78