27 lines
633 B
PHP
27 lines
633 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects\Stock;
|
|
|
|
use Domain\Models\ValueObjects\Actor\ActorId;
|
|
|
|
final readonly class StockAdjustment
|
|
{
|
|
public function __construct(
|
|
public int $quantity,
|
|
public string $reason,
|
|
public ActorId $actorId,
|
|
public ?\DateTimeInterface $createdAt = null,
|
|
) {
|
|
if ($this->quantity <= 0) {
|
|
throw new \DomainException('Stock Amount should be more than 0.');
|
|
}
|
|
|
|
$trimmed = mb_trim($reason);
|
|
|
|
if ($trimmed === '') {
|
|
throw new \DomainException('Reason cannot be empty.');
|
|
}
|
|
}
|
|
}
|