Add observer pattern to php
clean up code