I am getting to a point in my application where there seems to be a lot of presentation logic in my models:
<?php foreach ($this->users as $user): ?>
<span class="phone">
<?php echo $user->getPhoneNumberFormattedAsText(); ?>
</span>
<?php endforeach; ?>
At first, I started approaching this as a need for View Helpers:
<span class="phone"><?php echo $this->userPhone($user->getPhone()); ?></span>
However, I've started running into a problem where I have lots of little View Helpers that are specific to certain models, that don't need to take up an entire file. It would be nice if I could group this presentation logic together and keep it out of the model. I think this is when the decorator pattern makes sense.
"The decorator pattern is a design pattern that allows behaviour to be added to an existing object dynamically."
I have seen a few examples online, but no real, practical examples of code. I would like to know if you have successfully used this pattern in your PHP application and what a PHP example of this should look like.