/decorator-design-pattern-sample

Decorator pattern allows us to add new functionality to an existing object. This pattern requires a decorator class which wraps the original class in order to provide additional functionality. For now, we are going to implement a simple example using PHP and see how the decorator works.

Primary LanguagePHP

Decorator Design Pattern in PHP

Attaches additional responsibilities to an object dynamically.


Online shop

  • Different option for products may change the final price.
  • Discount may change the final price.
Price of T-Shirt is $30.
Price of Red T-Shirt is $40.
Price of Blue T-Shirt is $50.
Discount will reduce $10 of T-shirt price.

YouTube link

https://youtu.be/t3Oj4iYj0qc