OOP question involve AR - replace a relation with other object when related record not present?

OK, maybe the title of this sucks but…

I have the following situation. I have a table "Entries", each Entry has a date, description and some other fields. It also has column PaymentID, which is "belongs-to" relation to Payments table. In the payments table I keep lots of info regarding the payment that might have occured for the Entry. In view files when I display the entry, I would do:

echo $entry->payment->getAmount();

echo $entry->payment->getDescription();

Well, the entry might or might NOT have a Payment. So in case the PaymentID in Entries table is NULL, the above line fails and one solution would be to do a check every time I want to show the payment amount, or description or something else…

if (!empty($entry->payment))

But I dont like this! I imagine the following solution. I can create a "NoPayment" class that implements IPayment interface. The interface would specify all the methods that I have in the Payments AR model. The Payments AR model will implement the same interface. In the afterFind() of the Entries model I will check if there is a PaymentID. If not I will instantiate the NoPayment class, I will assign it to $this->payment and the getAmount() method for example would do:

return ‘No data’;

Does that make sense?

Thank you!

It’s better to check for empty payment…