Passed
Push — master ( 78b0a8...f52bee )
by Zoilo
01:54
created

HttpResponse::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 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Events\Common;
4
5
/**
6
 * HTTP response object, used by error, span and transction documents
7
 */
8
class HttpResponse implements \JsonSerializable
9
{
10
    /**
11
     * The status code of the http request.
12
     *
13
     * @var int|null
14
     */
15
    private $statusCode;
16
17
    /**
18
     * Total size of the payload.
19
     *
20
     * @var int|null
21
     */
22
    private $transferSize;
23
24
    /**
25
     * The encoded size of the payload.
26
     *
27
     * @var int|null
28
     */
29
    private $encodedBodySize;
30
31
    /**
32
     * The decoded size of the payload.
33
     *
34
     * @var int|null
35
     */
36
    private $decodedBodySize;
37
38
    /**
39
     * @var array|null
40
     */
41
    private $headers;
42
43
    /**
44
     * @param int|null $statusCode
45
     * @param int|null $transferSize
46
     * @param int|null $encodedBodySize
47
     * @param int|null $decodedBodySize
48
     * @param array|null $headers
49
     */
50 6
    public function __construct(
51
        $statusCode = null,
52
        $transferSize = null,
53
        $encodedBodySize = null,
54
        $decodedBodySize = null,
55
        array $headers = null
56
    ) {
57 6
        $this->statusCode = $statusCode;
58 6
        $this->transferSize = $transferSize;
59 6
        $this->encodedBodySize = $encodedBodySize;
60 6
        $this->decodedBodySize = $decodedBodySize;
61 6
        $this->headers = $headers;
62 6
    }
63
64
    /**
65
     * @return int|null
66
     */
67 1
    public function statusCode()
68
    {
69 1
        return $this->statusCode;
70
    }
71
72
    /**
73
     * @return int|null
74
     */
75 1
    public function transferSize()
76
    {
77 1
        return $this->transferSize;
78
    }
79
80
    /**
81
     * @return int|null
82
     */
83 1
    public function encodedBodySize()
84
    {
85 1
        return $this->encodedBodySize;
86
    }
87
88
    /**
89
     * @return int|null
90
     */
91 1
    public function decodedBodySize()
92
    {
93 1
        return $this->decodedBodySize;
94
    }
95
96
    /**
97
     * @return array|null
98
     */
99 1
    public function headers()
100
    {
101 1
        return $this->headers;
102
    }
103
104
    /**
105
     * @return array
106
     */
107 2
    public function jsonSerialize()
108
    {
109
        return [
110 2
            'status_code' => $this->statusCode,
111 2
            'transfer_size' => $this->transferSize,
112 2
            'encoded_body_size' => $this->encodedBodySize,
113 2
            'decoded_body_size' => $this->decodedBodySize,
114 2
            'headers' => $this->headers,
115 2
        ];
116
    }
117
}
118