Yes. It raises a lot of good points but the examples a bit meh.
I was thinking about how this...
$invoicedAmount = new Money(50, new Currency('CHF'));
$paidAmount = new Money(50, new Currency('CHF'));
if ($invoicedAmount->getAmount() === $paidAmount->getAmount() &&
$invoicedAmount->getCurrency()->getCode() === $paidAmount->getCurrency()->getCode()
) {
// do something
}
...seems a bit procedural itself and could be refactored to only doing one check.
$invoicedAmount = new Money(50, new Currency('CHF'));
$paidAmount = new Money(50, new Currency('CHF'));
if ($invoicedAmount->getAmount() === $paidAmount->getAmount())
) {
// do something
}
Currency differences can be dealt with in the Money
class.