LnBitsBackendConfig::setApiEndpoint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightning\Config\Backend;
6
7
final class LnBitsBackendConfig implements BackendConfigInterface
8
{
9
    private string $apiEndpoint = 'http://localhost:5000';
10
    private string $apiKey = '';
11
12 2
    private function __construct()
13
    {
14 2
    }
15
16 2
    public static function withEndpointAndKey(string $endpoint, string $key): self
17
    {
18 2
        return (new self())
19 2
            ->setApiEndpoint($endpoint)
20 2
            ->setApiKey($key);
21
    }
22
23
    /**
24
     * @return array{
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{ at position 2 could not be parsed: the token is null at position 2.
Loading history...
25
     *     api_endpoint: string,
26
     *     api_key: string
27
     * }
28
     */
29 2
    public function jsonSerialize(): array
30
    {
31 2
        return [
32 2
            'api_endpoint' => $this->apiEndpoint,
33 2
            'api_key' => $this->apiKey,
34 2
        ];
35
    }
36
37 2
    private function setApiEndpoint(string $apiEndpoint): self
38
    {
39 2
        $this->apiEndpoint = rtrim($apiEndpoint, '/');
40 2
        return $this;
41
    }
42
43 2
    private function setApiKey(string $apiKey): self
44
    {
45 2
        $this->apiKey = $apiKey;
46 2
        return $this;
47
    }
48
}
49