php refactoring, rest service