ldc-legaulois/app/Lib/Axepta/Objects/AxeptaOrder.php

38 lines
1,013 B
PHP
Raw Normal View History

2026-02-17 14:01:32 +00:00
<?php
declare(strict_types=1);
2026-02-17 14:01:32 +00:00
namespace App\Lib\Axepta\Objects;
use Illuminate\Support\Facades\Validator;
final readonly class AxeptaOrder
2026-02-17 14:01:32 +00:00
{
/**
* Construct method
*
* @param string $reference Internal system reference order
* @param integer $amount Order amount ex: 10000 = 100$
* @param string $customerEmail Customer email
* @return void
2026-02-17 14:01:32 +00:00
*/
public function __construct(
public string $reference,
public int $amount,
public string $customerEmail
) {
if (empty(trim($reference))) {
throw new \DomainException('Reference cannot be empty');
}
if ($amount <= 0) {
throw new \DomainException('Amount cannot be negative');
}
if (
empty(trim($customerEmail)) ||
Validator::make(['email' => $customerEmail], ['email' => 'email:rfc'])->fails()
) {
throw new \DomainException('A valid email is required');
}
}
}