Service::resource()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
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\Span\Context\Destination;
4
5
use ZoiloMora\ElasticAPM\Helper\Encoding;
6
7
final class Service implements \JsonSerializable
8
{
9
    /**
10
     * Type of the destination service (e.g. 'db', 'elasticsearch').
11
     * Should typically be the same as span.type.
12
     *
13
     * @var string
14
     */
15
    private $type;
16
17
    /**
18
     * Identifier for the destination service (e.g. 'http://elastic.co', 'elasticsearch', 'rabbitmq')
19
     *
20
     * @var string
21
     */
22
    private $name;
23
24
    /**
25
     * Identifier for the destination service resource being operated on
26
     * (e.g. 'http://elastic.co:80', 'elasticsearch', 'rabbitmq/queue_name')
27
     *
28
     * @var string
29
     */
30
    private $resource;
31
32
    /**
33
     * @param string $type
34
     * @param string $name
35
     * @param string $resource
36
     */
37 2
    public function __construct($type, $name, $resource)
38
    {
39 2
        $this->type = $type;
40 2
        $this->name = $name;
41 2
        $this->resource = $resource;
42 2
    }
43
44
    /**
45
     * @return string
46
     */
47 1
    public function type()
48
    {
49 1
        return $this->type;
50
    }
51
52
    /**
53
     * @return string
54
     */
55 1
    public function name()
56
    {
57 1
        return $this->name;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 1
    public function resource()
64
    {
65 1
        return $this->resource;
66
    }
67
68
    /**
69
     * @return array
70
     */
71 1
    public function jsonSerialize()
72
    {
73
        return [
74 1
            'type' => Encoding::keywordField($this->type),
75 1
            'name' => Encoding::keywordField($this->name),
76 1
            'resource' => Encoding::keywordField($this->resource),
77 1
        ];
78
    }
79
}
80