Passed
Push — master ( 2fd9ef...607eaa )
by Zoilo
03:42
created

Span::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Processor\MetricSetProcessor;
4
5
final class Span implements \JsonSerializable
6
{
7
    /**
8
     * @var string
9
     */
10
    private $transactionId;
11
12
    /**
13
     * @var string
14
     */
15
    private $type;
16
17
    /**
18
     * @var string|null
19
     */
20
    private $subType;
21
22
    /**
23
     * @var int
24
     */
25
    private $count;
26
27
    /**
28
     * @var double
29
     */
30
    private $sum;
31
32
    /**
33
     * @param string $transactionId
34
     * @param string $type
35
     * @param string|null $subType
36
     * @param int $count
37
     * @param double $sum
38
     */
39 7
    public function __construct($transactionId, $type, $subType, $count, $sum)
40
    {
41 7
        $this->transactionId = $transactionId;
42 7
        $this->type = $type;
43 7
        $this->subType = $subType;
44 7
        $this->count = $count;
45 7
        $this->sum = $sum;
46 7
    }
47
48
    /**
49
     * @return string
50
     */
51 4
    public function transactionId()
52
    {
53 4
        return $this->transactionId;
54
    }
55
56
    /**
57
     * @return string
58
     */
59 4
    public function type()
60
    {
61 4
        return $this->type;
62
    }
63
64
    /**
65
     * @return string|null
66
     */
67 4
    public function subType()
68
    {
69 4
        return $this->subType;
70
    }
71
72
    /**
73
     * @return int
74
     */
75 4
    public function count()
76
    {
77 4
        return $this->count;
78
    }
79
80
    /**
81
     * @return double
82
     */
83 4
    public function sum()
84
    {
85 4
        return $this->sum;
86
    }
87
88
    /**
89
     * @return array
90
     */
91 1
    public function jsonSerialize()
92
    {
93
        return [
94 1
            'transaction_id' => $this->transactionId,
95 1
            'type' => $this->type,
96 1
            'sub_type' => $this->subType,
97 1
            'count' => $this->count,
98 1
            'sum' => $this->sum,
99 1
        ];
100
    }
101
}
102