31 lines
603 B
PHP
31 lines
603 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Domain\Models\ValueObjects;
|
||
|
|
|
||
|
|
use Shared\DDD\Models\Equatable;
|
||
|
|
use Shared\ValueObjects\Money;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Wraps a Money value as a requested/expected monetary amount.
|
||
|
|
*/
|
||
|
|
final readonly class MoneyAmount implements \Stringable, Equatable
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public Money $value,
|
||
|
|
) {
|
||
|
|
}
|
||
|
|
|
||
|
|
#[\Override]
|
||
|
|
public function equals(mixed $other): bool
|
||
|
|
{
|
||
|
|
return $other instanceof self && $this->value->equals($other->value);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function __toString(): string
|
||
|
|
{
|
||
|
|
return (string) $this->value;
|
||
|
|
}
|
||
|
|
}
|