Runtime   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 57
ccs 16
cts 16
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A version() 0 3 1
A jsonSerialize() 0 5 1
A __construct() 0 4 1
A discover() 0 5 1
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Events\Common\Service;
4
5
use ZoiloMora\ElasticAPM\Helper\Encoding;
6
7
final class Runtime implements \JsonSerializable
8
{
9
    /**
10
     * @var string|null
11
     */
12
    private $name;
13
14
    /**
15
     * @var string|null
16
     */
17
    private $version;
18
19
    /**
20
     * @param string|null $name
21
     * @param string|null $version
22
     */
23 16
    public function __construct($name = null, $version = null)
24
    {
25 16
        $this->name = $name;
26 16
        $this->version = $version;
27 16
    }
28
29
    /**
30
     * @return string|null
31
     */
32 13
    public function name()
33
    {
34 13
        return $this->name;
35
    }
36
37
    /**
38
     * @return string|null
39
     */
40 13
    public function version()
41
    {
42 13
        return $this->version;
43
    }
44
45
    /**
46
     * @return Runtime
47
     */
48 13
    public static function discover()
49
    {
50 13
        return new self(
51 13
            'php',
52 13
            (string) phpversion()
53 13
        );
54
    }
55
56
    /**
57
     * @return array
58
     */
59 1
    public function jsonSerialize()
60
    {
61
        return [
62 1
            'name' => Encoding::keywordField($this->name),
63 1
            'version' => Encoding::keywordField($this->version),
64 1
        ];
65
    }
66
}
67