Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class UserRepository
  2. {
  3. private $users = [];
  4.  
  5. function __construct(UserDataMapper $dm){
  6. $this->dataMapper = $dm;
  7. }
  8.  
  9. function getByID($id){
  10. if(!isset($this->users[$id])){
  11. $this->users[$id] = $this->dataMapper->getByID($id);
  12. }
  13. return $this->users[$id];
  14. }
  15. }
  16.  
  17.  
  18. $dm = new MysqlUserDataMapper($..., $...);
  19.  
  20. $repo = new UserRepository($dm);
  21.  
  22. $user = $repo->getByID(232);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement