| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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{ |
||
|
|
|||
| 25 | * api_endpoint: string, |
||
| 26 | * api_key: string |
||
| 27 | * } |
||
| 28 | */ |
||
| 29 | 3 | public function jsonSerialize(): array |
|
| 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 |
|
| 47 | } |
||
| 48 | } |
||
| 49 |