Issues (21)

src/Config/Backend/LnBitsBackendConfig.php (1 issue)

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