php design pattern implementation