Passed
Push — master ( 6f8d38...e8d96c )
by Zoilo
01:45
created

Response::headers()   A

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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Events\Common\Context;
4
5
final class Response implements \JsonSerializable
6
{
7
    /**
8
     * A boolean indicating whether the response was finished or not
9
     *
10
     * @var bool|null
11
     */
12
    private $finished;
13
14
    /**
15
     * A mapping of HTTP headers of the response object
16
     *
17
     * @var array|null
18
     */
19
    private $headers;
20
21
    /**
22
     * @var bool|null
23
     */
24
    private $headersSent;
25
26
    /**
27
     * The HTTP status code of the response.
28
     *
29
     * @var int|null
30
     */
31
    private $statusCode;
32
33
    /**
34
     * @param bool|null $finished
35
     * @param array|null $headers
36
     * @param bool|null $headersSent
37
     * @param int|null $statusCode
38
     */
39 3
    public function __construct(
40
        $finished = null,
41
        array $headers = null,
42
        $headersSent = null,
43
        $statusCode = null
44
    ) {
45 3
        $this->finished = $finished;
46 3
        $this->headers = $headers;
47 3
        $this->headersSent = $headersSent;
48 3
        $this->statusCode = $statusCode;
49 3
    }
50
51
    /**
52
     * @return bool|null
53
     */
54 1
    public function finished()
55
    {
56 1
        return $this->finished;
57
    }
58
59
    /**
60
     * @return array|null
61
     */
62 1
    public function headers()
63
    {
64 1
        return $this->headers;
65
    }
66
67
    /**
68
     * @return bool|null
69
     */
70 1
    public function headersSent()
71
    {
72 1
        return $this->headersSent;
73
    }
74
75
    /**
76
     * @return int|null
77
     */
78 1
    public function statusCode()
79
    {
80 1
        return $this->statusCode;
81
    }
82
83
    /**
84
     * @return array
85
     */
86 1
    public function jsonSerialize()
87
    {
88
        return [
89 1
            'finished' => $this->finished,
90 1
            'headers' => $this->headers,
91 1
            'headers_sent' => $this->headersSent,
92 1
            'status_code' => $this->statusCode,
93 1
        ];
94
    }
95
}
96