Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserRepository
- {
- private $users = [];
- function __construct(UserDataMapper $dm){
- $this->dataMapper = $dm;
- }
- function getByID($id){
- if(!isset($this->users[$id])){
- $this->users[$id] = $this->dataMapper->getByID($id);
- }
- return $this->users[$id];
- }
- }
- $dm = new MysqlUserDataMapper($..., $...);
- $repo = new UserRepository($dm);
- $user = $repo->getByID(232);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement