Download the PHP package andydune/conditional-execution without Composer
On this page you can find all versions of the php package andydune/conditional-execution. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andydune/conditional-execution
More information about andydune/conditional-execution
Files in andydune/conditional-execution
Package conditional-execution
Short Description It allows for conditional execution of code fragments more beautiful and testable.
License MIT
Homepage https://github.com/AndyDune/ConditionalExecution
Informations about the package conditional-execution
ConditionalExecution
It allows for conditional execution of code fragments more beautiful and testable. Line code with no indentation prevents appearance of errors and improves readability.
Requirements
- PHP version >= 5.6
- A candy for your friend in store
Installation
Installation using composer:
Or if composer was not installed globally:
Or edit your composer.json
:
And execute command:
See a problem
Here condition for execution. I meet something like this it in many CMS ofter:
It's difficult to read, search error or edit.
This is better way library offers:
Methods
add($condition)
It adds condition to a queue. Condition is not check immediately. It can be callable.
bindAnd()
Change bind of conditions to AND logic. AND is used as default.
bindOr()
Change bind of conditions to OR logic.
check()
It executes check of all collected conditions.
doIt()
It checks of all collected conditions and execute appropriate function and triggers.
Benefit
Simple add or delete conditions
You don't need to count brackets. Add, remove conditions is simple.
Closure as condition and params
You can use closure as condition. Function can receive params witch was inserted with doIt
or check
methods.
Check classes for checks of any complexity
There is mechanic for check of any complexity. It is describes as instance of AndyDune\ConditionalExecution\Check\CheckAbstract
.
You may create your own custom class and use it.
ArrayValueWithKeyNotEmpty
It checks array value with key is not empty.
ArrayHasNotEmptyValueOrKeyNotExist
Given array key must not exist or keep value == true
Execute functions in list for get first result
With params: