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

37 lines
993 B
PHP
Raw Permalink 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
*
2026-09-25 16:25:31 +02:00
* @param string $reference Internal system reference order
* @param int $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 (
2026-09-25 16:25:31 +02:00
empty(trim($customerEmail)) || Validator::make(['email' => $customerEmail], ['email' => 'email:rfc'])->fails()
) {
throw new \DomainException('A valid email is required');
}
}
}