Skip to content

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.

Notifications You must be signed in to change notification settings

majidkarimizadeh/decorator-design-pattern-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages