Skip to content

Commit

Permalink
create Application layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Jul 6, 2024
1 parent d6fa972 commit 63d9b1c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"@csfix",
"@test-all"
],
"fix": "@csfix",
"test": "@test-all",
"test-all": [
"@quality",
"@phpunit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

declare(strict_types=1);

namespace PhpLightning\Invoice\Domain\CallbackUrl;
namespace PhpLightning\Invoice\Application;

use PhpLightning\Invoice\Domain\CallbackUrl\CallbackUrlInterface;
use PhpLightning\Invoice\Domain\CallbackUrl\LnAddressGeneratorInterface;
use PhpLightning\Shared\Value\SendableRange;

final class CallbackUrl implements CallbackUrlInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpLightning\Invoice\Domain\LnAddress;
namespace PhpLightning\Invoice\Application;

use PhpLightning\Invoice\Domain\BackendInvoice\BackendInvoiceInterface;
use PhpLightning\Shared\Transfer\BackendInvoiceResponse;
Expand Down
2 changes: 1 addition & 1 deletion src/Invoice/Domain/CallbackUrl/LnAddressGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(

public function generate(?string $username): string
{
if (empty($username)) {
if ($username === null || $username === '') {
return $this->defaultLnAddress;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Invoice/InvoiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace PhpLightning\Invoice;

use Gacela\Framework\AbstractFactory;
use PhpLightning\Invoice\Application\CallbackUrl;
use PhpLightning\Invoice\Application\InvoiceGenerator;
use PhpLightning\Invoice\Domain\BackendInvoice\BackendInvoiceInterface;
use PhpLightning\Invoice\Domain\BackendInvoice\LnbitsBackendInvoice;
use PhpLightning\Invoice\Domain\CallbackUrl\CallbackUrl;
use PhpLightning\Invoice\Domain\CallbackUrl\CallbackUrlInterface;
use PhpLightning\Invoice\Domain\CallbackUrl\LnAddressGenerator;
use PhpLightning\Invoice\Domain\CallbackUrl\LnAddressGeneratorInterface;
use PhpLightning\Invoice\Domain\Http\HttpApiInterface;
use PhpLightning\Invoice\Domain\LnAddress\InvoiceGenerator;

/**
* @method InvoiceConfig getConfig()
Expand Down
19 changes: 19 additions & 0 deletions src/Shared/Transfer/BackendInvoiceResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
final class BackendInvoiceResponse
{
private string $status = 'OK';

private string $paymentRequest = '';

/** @var list<string> */
private array $successAction = [];

/** @var list<string> */
private array $routes = [];

private bool $disposable = false;

private string $reason = '';

public function getPaymentRequest(): string
Expand All @@ -35,22 +42,34 @@ public function setStatus(string $status): self
return $this;
}

/**
* @return list<string>
*/
public function getSuccessAction(): array
{
return $this->successAction;
}

/**
* @param list<string> $successAction
*/
public function setSuccessAction(array $successAction): self
{
$this->successAction = $successAction;
return $this;
}

/**
* @return list<string>
*/
public function getRoutes(): array
{
return $this->routes;
}

/**
* @param list<string> $routes
*/
public function setRoutes(array $routes): self
{
$this->routes = $routes;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Invoice/Domain/CallbackUrl/CallbackUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace PhpLightningTest\Unit\Invoice\Domain\CallbackUrl;

use PhpLightning\Invoice\Application\CallbackUrl;
use PhpLightning\Invoice\Domain\BackendInvoice\BackendInvoiceInterface;
use PhpLightning\Invoice\Domain\CallbackUrl\CallbackUrl;
use PhpLightning\Invoice\Domain\CallbackUrl\LnAddressGeneratorInterface;
use PhpLightning\Shared\Transfer\BackendInvoiceResponse;
use PhpLightning\Shared\Value\SendableRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace PhpLightningTest\Unit\Invoice\Domain\LnAddress;

use PhpLightning\Invoice\Application\InvoiceGenerator;
use PhpLightning\Invoice\Domain\BackendInvoice\BackendInvoiceInterface;
use PhpLightning\Invoice\Domain\LnAddress\InvoiceGenerator;
use PhpLightning\Shared\Transfer\BackendInvoiceResponse;
use PhpLightning\Shared\Value\SendableRange;
use PHPUnit\Framework\TestCase;
Expand Down

0 comments on commit 63d9b1c

Please sign in to comment.