ClientConfiguration   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 45
c 0
b 0
f 0
wmc 6
lcom 2
cbo 0
ccs 15
cts 15
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getTransactionsEndpoint() 0 4 1
A getErrorsEndpoint() 0 4 1
A authenticatedByToken() 0 7 1
A needsAuthentication() 0 4 1
A getToken() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TechDeCo\ElasticApmAgent;
5
6
use function rtrim;
7
8
final class ClientConfiguration
9
{
10
    /**
11
     * @var string
12
     */
13
    private $url;
14
15
    /**
16
     * @var string
17
     */
18
    private $token;
19
20 12
    public function __construct(string $url)
21
    {
22 12
        $this->url = rtrim($url, '/');
23 12
    }
24
25 10
    public function getTransactionsEndpoint(): string
26
    {
27 10
        return $this->url . '/v1/transactions';
28
    }
29
30 2
    public function getErrorsEndpoint(): string
31
    {
32 2
        return $this->url . '/v1/errors';
33
    }
34
35 11
    public function authenticatedByToken(string $token): self
36
    {
37 11
        $config        = clone $this;
38 11
        $config->token = $token;
39
40 11
        return $config;
41
    }
42
43 12
    public function needsAuthentication(): bool
44
    {
45 12
        return $this->token !== null;
46
    }
47
48 11
    public function getToken(): string
49
    {
50 11
        return $this->token;
51
    }
52
}
53