Language   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 jsonSerialize() 0 5 1
A __construct() 0 4 1
A name() 0 3 1
A version() 0 3 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
/**
8
 * Name and version of the programming language used
9
 */
10
final class Language implements \JsonSerializable
11
{
12
    /**
13
     * @var string|null
14
     */
15
    private $name;
16
17
    /**
18
     * @var string|null
19
     */
20
    private $version;
21
22
    /**
23
     * @param string|null $name
24
     * @param string|null $version
25
     */
26 16
    public function __construct($name = null, $version = null)
27
    {
28 16
        $this->name = $name;
29 16
        $this->version = $version;
30 16
    }
31
32
    /**
33
     * @return string|null
34
     */
35 13
    public function name()
36
    {
37 13
        return $this->name;
38
    }
39
40
    /**
41
     * @return string|null
42
     */
43 1
    public function version()
44
    {
45 1
        return $this->version;
46
    }
47
48
    /**
49
     * @return Language
50
     */
51 13
    public static function discover()
52
    {
53 13
        return new self(
54 13
            'php',
55 13
            (string) phpversion()
56 13
        );
57
    }
58
59
    /**
60
     * @return array
61
     */
62 1
    public function jsonSerialize()
63
    {
64
        return [
65 1
            'name' => Encoding::keywordField($this->name),
66 1
            'version' => Encoding::keywordField($this->version),
67 1
        ];
68
    }
69
}
70