Framework::name()   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\Common\Service;
4
5
use ZoiloMora\ElasticAPM\Configuration\CoreConfiguration;
6
use ZoiloMora\ElasticAPM\Helper\Encoding;
7
8
final class Framework implements \JsonSerializable
9
{
10
    /**
11
     * @var string|null
12
     */
13
    private $name;
14
15
    /**
16
     * @var string|null
17
     */
18
    private $version;
19
20
    /**
21
     * @param string|null $name
22
     * @param string|null $version
23
     */
24 16
    public function __construct($name = null, $version = null)
25
    {
26 16
        $this->name = $name;
27 16
        $this->version = $version;
28 16
    }
29
30
    /**
31
     * @param CoreConfiguration $coreConfiguration
32
     *
33
     * @return Framework
34
     */
35 13
    public static function create(CoreConfiguration $coreConfiguration)
36
    {
37 13
        return new self(
38 13
            $coreConfiguration->frameworkName(),
39 13
            $coreConfiguration->frameworkVersion()
40 13
        );
41
    }
42
43
    /**
44
     * @return string|null
45
     */
46 2
    public function name()
47
    {
48 2
        return $this->name;
49
    }
50
51
    /**
52
     * @return string|null
53
     */
54 2
    public function version()
55
    {
56 2
        return $this->version;
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