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

Http::statusCode()   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\Span\Context;
4
5
use ZoiloMora\ElasticAPM\Helper\Encoding;
6
7
/**
8
 * An object containing contextual data of the related http request.
9
 */
10
final class Http implements \JsonSerializable
11
{
12
    /**
13
     * The raw url of the correlating http request.
14
     *
15
     * @var string|null
16
     */
17
    private $url;
18
19
    /**
20
     * The status code of the http request.
21
     *
22
     * @var int|null
23
     */
24
    private $statusCode;
25
26
    /**
27
     * The method of the http request.
28
     *
29
     * @var string|null
30
     */
31
    private $method;
32
33
    /**
34
     * @param string|null $url
35
     * @param int|null $statusCode
36
     * @param string|null $method
37
     */
38 3
    public function __construct(
39
        $url = null,
40
        $statusCode = null,
41
        $method = null
42
    ) {
43 3
        $this->url = $url;
44 3
        $this->statusCode = $statusCode;
45 3
        $this->method = $method;
46 3
    }
47
48
    /**
49
     * @return string|null
50
     */
51 1
    public function url()
52
    {
53 1
        return $this->url;
54
    }
55
56
    /**
57
     * @return int|null
58
     */
59 1
    public function statusCode()
60
    {
61 1
        return $this->statusCode;
62
    }
63
64
    /**
65
     * @return string|null
66
     */
67 1
    public function method()
68
    {
69 1
        return $this->method;
70
    }
71
72
    /**
73
     * @return array
74
     */
75 1
    public function jsonSerialize()
76
    {
77
        return [
78 1
            'url' => $this->url,
79 1
            'status_code' => $this->statusCode,
80 1
            'method' => Encoding::keywordField($this->method),
81 1
        ];
82
    }
83
}
84