Refactor PHP classes