Download the PHP package theroadbunch/bouncer without Composer
On this page you can find all versions of the php package theroadbunch/bouncer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download theroadbunch/bouncer
More information about theroadbunch/bouncer
Files in theroadbunch/bouncer
Package bouncer
Short Description Bouncer is an easy-to-use allow/deny list interface.
License MIT
Informations about the package bouncer
📋 Bouncer
What is Bouncer?
Bouncer is an easy-to-use allow/deny list interface.
Why the name Bouncer?
In the real-world, a bouncer holds the list of who is allowed entry and who is not.
- AllowBouncer: At an exclusive club, the bouncer has a list and if you're not on it, you can't come in.
- DenyBouncer: The local bar allows almost everyone in, the bouncer has a list of trouble-makers to stop at the door.
Contents
- Installation
- Implementation
- Standard Usage
- Real-World Use-Case
- Bouncers
- Abstract Bouncer
- License
Install using composer [?]
composer require theroadbunch/bouncer
Implementation
Standard Usage
Use Bouncer::allow()
or Bouncer::deny()
to create your allow/deny lists (bouncer).
Update the Bouncer in real time
Using BouncerFactory::create()
This has been deprecated and will be removed from the documentation in version 2.4
Example of a real-world use-case
Bouncers
All bouncers implement RoadBunch\Bouncer\BouncerInterface
RoadBunch\Bouncer\AllowBouncer
method | description | return type |
---|---|---|
isAllowed(string $subject) | returns true if the subject is on the allow list |
bool |
allow(string $subject) | Add this subject to the allow list | void |
deny(string $subject) | Remove this subject from the allow list | void |
RoadBunch\Bouncer\DenyBouncer
method | description | return type |
---|---|---|
isAllowed(string $subject) | returns true if the subject is NOT on the deny list |
bool |
allow(string $subject) | Remove this subject from the deny list | void |
deny(string $subject) | Add this subject to the deny list | void |
Abstract Bouncer
RoadBunch\Bouncer\AbstractBouncer
implements RoadBunch\Bouncer\BouncerInterface
and is available to extend if you need to write your own logic to determine if a subject is allowed.
method | description | return type |
---|---|---|
has(string $subject) | returns true if a subject is held in the subject pool |
bool |
add(string $subject) | Add this subject to the pool | void |
remove(string $subject) | Remove this subject from the pool | void |
License
© Dan McAdams | The content of this library is released under the MIT License
You can find a copy of this license in http://opensource.org/licenses/mit.