47 lines
1 KiB
PHP
47 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Cqs\Actions\Customers;
|
|
|
|
use App\Enums\RegisterCustomerStatus;
|
|
use App\Models\Customer;
|
|
|
|
final readonly class RegisterCustomerOutput
|
|
{
|
|
private function __construct(
|
|
public RegisterCustomerStatus $status,
|
|
public ?Customer $customer = null,
|
|
public ?string $errorMessage = null,
|
|
) {
|
|
}
|
|
|
|
public static function success(Customer $customer): self
|
|
{
|
|
return new self(
|
|
status: RegisterCustomerStatus::SUCCESS,
|
|
customer: $customer,
|
|
);
|
|
}
|
|
|
|
public static function employeeAlreadyRegistered(): self
|
|
{
|
|
return new self(
|
|
status: RegisterCustomerStatus::EMPLOYEE_ALREADY_REGISTERED,
|
|
);
|
|
}
|
|
|
|
public static function employeeInactive(): self
|
|
{
|
|
return new self(
|
|
status: RegisterCustomerStatus::EMPLOYEE_INACTIVE,
|
|
);
|
|
}
|
|
|
|
public static function lockTimeout(): self
|
|
{
|
|
return new self(
|
|
status: RegisterCustomerStatus::LOCK_TIMEOUT,
|
|
);
|
|
}
|
|
}
|