Download the PHP package stamina/chequer-php without Composer
On this page you can find all versions of the php package stamina/chequer-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package chequer-php
Chequer 0.2
THE SPARKLING NEW LANGUAGE FOR CHECKING THINGS IN A SANE WAY
Match scalars, arrays, objects and grumpy cats against the query of Your choice!
Checkout the chequer.stamina.pl for more information!
Oh wait! There is more!
Part of the package is DynamicObject
class, which lets you dynamically create classes in PHP,
modify object's methods on the fly, extend objects and moar! Go check it out!
It's here to make typecasting easy, but it's pretty awesome on it's own!
Install
Use Composer package stamina/chequer-php
to install.
The minimum required PHP version is 5.3. Because 5.4 introduces the shorthand array syntax - this version is recommended and used in this documentation.
Usage and examples
Usage
There are a couple of usage patterns to choose from.
Simple checks
For simple checks use static function checkValue()
Reusing the query
When you want to reuse your query, or pass it somewhere as a callback, create the object and call check
method,
or invoke the object.
Global configuration
You can store all your queries in configuration files and use them when they are needed. This way you can separate your validation/filtering logic from your code - just like you do with the templates!
As every query
is a scalar
or an array
- they can be easely stored in JSON, YAML, MongoDB - you name it.
Dependency injection
If you rather prefer DI - fret not. You can add rules to Chequer
objects directly, which means you can
make a factory, or pass the Chequer
object around and still populate it with predefined rules.
The above example rewritten as Silex factory:
Note, that the whole idea is very fresh. I've come up with the concept on January 29th, and made the lib the same day.
And that means - it will change!
©2013 Rafal Lindemann