File size: 1,269 Bytes
cf14c12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <?php
declare(strict_types=1);
namespace Billing\Application\Commands;
use Billing\Application\CommandHandlers\ReadSubscriptionCommandHandler;
use Billing\Domain\ValueObjects\ExternalId;
use Billing\Domain\ValueObjects\PaymentGateway;
use Shared\Domain\ValueObjects\Id;
use Shared\Infrastructure\CommandBus\Attributes\Handler;
#[Handler(ReadSubscriptionCommandHandler::class)]
class ReadSubscriptionCommand
{
public ?Id $id = null;
public ?PaymentGateway $gateway = null;
public ?ExternalId $externalId = null;
/** @return void */
private function __construct()
{
}
/**
* @param string $gateway
* @param string $externalId
* @return ReadSubscriptionCommand
*/
public static function createByExternalId(
string $gateway,
string $externalId,
): ReadSubscriptionCommand {
$cmd = new self;
$cmd->externalId = new ExternalId($externalId);
$cmd->gateway = new PaymentGateway($gateway);
return $cmd;
}
/**
* @param string $id
* @return ReadSubscriptionCommand
*/
public static function createById(string $id): ReadSubscriptionCommand
{
$cmd = new self;
$cmd->id = new Id($id);
return $cmd;
}
}
|