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

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 5
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