Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Interface IPosts{}
- Interface IComments{}
- # Models
- Class CommentsMysqlModel implements IComments{}
- Class CommentsMongoDBModel implements IComments{}
- Class PostsMysqlModel implements IPosts{}
- Class PostsMongoDBModel implements IPosts{}
- # Classes
- Class Posts {
- private $postsModel;
- private $commentsModel;
- public function __construct(IPosts $postsModel,IComments $commentsModel){
- $this->postsModel = $PostsModel;
- $this->commentsModel = $commentsModel;
- }
- }
- // Example Of Usage
- # IF I would like to use mysql for both
- $comments = new CommentsMysqModel;
- $posts = new PostsMysqModel;
- $postClass = new Posts($posts,$comments);
- // So if i would like to use comments for mongodb
- $comments = new CommentsMongoDBModel;
- $posts = new PostsMysqModel;
- $postClass = new Posts($posts,$comments);
- // That's it
Add Comment
Please, Sign In to add comment