$> git checkout decorator
Intent
Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.1
Applications
Decorators extend functionality. How are decorators different than mere inheritance? Classical inheritance extends functionality of classes before runtime. Decorators extend functionality of real-time objects during runtime. The decorator wraps an real object, giving us the ability to change object behavior at runtime. It may seem weird to talk about runtime and PHP, since PHP is an interrupted language and not ...