25 lines
613 B
PHP
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);
|
|
}
|
|
} |