Practical design patterns in PHP (Part 2)
summary
Workshop builds a coupon system that combines a Decorator pattern for unlimited restrictions (limited lifetime, first‑order, minimum purchase) with concrete coupons: value coupon (subtracts €20) and rate coupon (20% / 0.20). It uses a Coupon builder to assemble decorators in a controlled order and a small factory variant; tests use the Symfony PHPunit bridge to mock the clock, tests pass, code is in Arab-dot-com/hhamon/websummercamp and examples demonstrate working combinations like 20% off on ≥€75 within a date range.
AI-written summary · about
chapters (16)
- 0:00Decorator pattern intro
- 4:33Defining coupon interface
- 7:25Concrete coupon classes
- 11:31Rate coupon implementation
- 14:45Restricted coupon decorator
- 19:00Limited lifetime coupon
- 24:13Testing with clock mocking
- 28:59Validating coupon restrictions
- 35:38Advanced coupon combinations
- 43:42Adapter pattern concepts
- 52:37Prototype pattern in PHP
- 1:03:07Builder pattern fundamentals
- 1:14:23Coupon builder implementation
- 1:39:06Abstract factory pattern
- 2:04:24Factory method pattern
- 2:15:03Factory and builder refactor








