Passed
Push — main ( 730824...30ce88 )
by Chema
16:47 queued 07:53
created

LnBitsBackendConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
ccs 1
cts 1
cp 1
crap 1
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 3
    private function __construct()
13
    {
14 3
    }
15
16 3
    public static function withEndpointAndKey(string $endpoint, string $key): self
17
    {
18 3
        return (new self())
19 3
            ->setApiEndpoint($endpoint)
20 3
            ->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 3
    public function jsonSerialize(): array
30
    {
31 3
        return [
32 3
            'api_endpoint' => $this->apiEndpoint,
33 3
            'api_key' => $this->apiKey,
34 3
        ];
35
    }
36
37 3
    private function setApiEndpoint(string $apiEndpoint): self
38
    {
39 3
        $this->apiEndpoint = rtrim($apiEndpoint, '/');
40 3
        return $this;
41
    }
42
43 3
    private function setApiKey(string $apiKey): self
44
    {
45 3
        $this->apiKey = $apiKey;
46 3
        return $this;
47
    }
48
}
49