Passed
Push — main ( 087f6d...b5e930 )
by Chema
53s queued 13s
created

Lightning::getCallbackUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightning;
6
7
use Closure;
8
use Gacela\Framework\Bootstrap\GacelaConfig;
9
use PhpLightning\Invoice\InvoiceFacade;
10
11
final class Lightning
12
{
13
    public const CONFIG_FILE = 'lightning-config.php';
14
15
    private const CONFIG_LOCAL_FILE = 'lightning-config-local.php';
16
17 1
    public static function getCallbackUrl(): string
18
    {
19 1
        $invoice = (new InvoiceFacade())->getCallbackUrl();
20
21 1
        return json_encode($invoice, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
22
    }
23
24 1
    public static function generateInvoice(int $amount, string $backend = 'lnbits'): string
25
    {
26 1
        $invoice = (new InvoiceFacade())->generateInvoice($amount, $backend);
27
28 1
        return json_encode($invoice, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
29
    }
30
31
    /**
32
     * @codeCoverageIgnore
33
     *
34
     * @return Closure(GacelaConfig):void
35
     */
36
    public static function configFn(): Closure
37
    {
38
        return static function (GacelaConfig $config): void {
39
            $config->addAppConfig(self::CONFIG_FILE, self::CONFIG_LOCAL_FILE);
40
            $config->setFileCacheEnabled(true);
41
            $config->setFileCacheDirectory('data/.cache');
42
        };
43
    }
44
}
45