Files
hedge-fund-ddd-poc/packages/mmt/ddd-shared-kernel/ValueObjects/PositiveMoney.php
2026-01-06 10:46:49 -05:00

25 lines
613 B
PHP

<?php
namespace MMT\DDDSharedKernel\ValueObjects;
class PositiveMoney extends ValueObject
{
public function __construct(
private Money $money
)
{
if($this->money->isNegative()) {
throw new \InvalidArgumentException("The value cannot be negative");
}
}
public function greaterThan(PositiveMoney $positiveMoney): bool
{
return $this->money->greaterThan($positiveMoney->money);
}
public function greaterThanOrEqual(PositiveMoney $positiveMoney): bool
{
return $this->money->greaterThanOrEqual($positiveMoney->money);
}
}