ClientConfiguration::needsAuthentication()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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