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

Response   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 88
ccs 19
cts 19
cp 1
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A statusCode() 0 3 1
A finished() 0 3 1
A headers() 0 3 1
A jsonSerialize() 0 7 1
A headersSent() 0 3 1
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