I have a repository for my business objects, and I neet to create different objects based on the data. Should I create them in the repo directly or move that code somewhere else - to the factory or some class in the business logic layer?
/**
* @returns Applier
*/
class ApplierRepository implements IApplierRepositoryInterface {
//some code
public function find($id) {
$data = $this->findBySql($id);
//Is it a business logic?
if($data['profile_id'] != null)
$object = new ProfileApplier();
if($data['user_id'] != null) {
$user = $this->userRepository->find($data['user_id']);
$object = new UserApplier($user);
}
//...
return $object;
}
}
Aucun commentaire:
Enregistrer un commentaire