Passed
Pull Request — master (#4)
by
unknown
02:33
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 17
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAgentConfiguration() 0 10 1
A __construct() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SamuelBednarcik\ElasticAPMAgent;
6
7
use SamuelBednarcik\ElasticAPMAgent\Builder\MetadataBuilder;
8
use SamuelBednarcik\ElasticAPMAgent\Events\Metadata;
9
10
final class Configuration
11
{
12
    /** @var string */
13
    private $serviceName;
14
15
    /** @var string */
16
    private $serverUrl;
17
18
    /** @var string|null */
19
    private $version;
20
21
    /** @var string|null */
22
    private $environment;
23
24
    /** @var string|null */
25
    private $framework;
26
27
    public function __construct(
28
        string $serviceName,
29
        string $serverUrl,
30
        ?string $version = null,
31
        ?string $environment = null,
32
        ?string $framework = null
33
    ) {
34
        $this->serviceName = $serviceName;
35
        $this->serverUrl = $serverUrl;
36
        $this->version = $version;
37
        $this->environment = $environment;
38
        $this->framework = $framework;
39
    }
40
41
    public function getAgentConfiguration(): AgentConfiguration
42
    {
43
        $metadata = new Metadata(
44
            MetadataBuilder::buildService($this->serviceName, $this->version, $this->environment, $this->framework)
45
        );
46
47
        return new AgentConfiguration(
48
            $this->serviceName,
49
            $this->serverUrl,
50
            $metadata
51
        );
52
    }
53
}
54