Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface AccessControl
- {
- public function userCan($action);
- }
- class BitmaskAccessControl implements AccessControl
- {
- public function userCan($action)
- {
- // bitmask comparison here based on $action
- // return bool
- }
- }
- class SomeOtherAccessControl implements AccessControl
- {
- public function userCan($action)
- {
- // some other type of comparison you have implemented
- // that does not use bitmask
- // return bool
- }
- }
- // When I ask for AccessControl give me the bitmask implementation
- $app->bind('AccessControl', 'BitmaskAccessControl');
- // Later on you decide to use your new implementation
- // When I ask for AccessControl give me the other implementation
- $app->bind('AccessControl', 'SomeOtherAccessControl');
- // Now none of your code other than
- // the one line above needs updated even when completely removing the bitmask stuff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement