Download the PHP package setherator/variables without Composer
On this page you can find all versions of the php package setherator/variables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download setherator/variables
More information about setherator/variables
Files in setherator/variables
Package variables
Short Description The Setherator Variable management library. Manages and processes variable values with some additional magic.
License MIT
Homepage https://github.com/setherator/variables
Informations about the package variables
Variables
The Setherator Variable management library. Manages and processes variable values with some additional magic.
Install
Via Composer
Usage
A compilation of several use cases of Variables
and it's helpers.
Will result in:
Helpers
A variable value can be any scalar, array, object type but also closure which will be executed and cached. To prevent caching value should implement NonCacheableClosure
interface for e.g. factory
helper function.
Reference
A function to fetch variable value from Variables instance. If not found $default = null
will be returned. If raw value before evaluation required use $raw = true
.
To fetch value at variable get time use these functions.
Enviroment variable
A function to fetch environment variable. If not found $default = null
will be returned.
Context
A function to wrap your closure and inject context from Variables::getContext()
;
Will return your closure wrapped with context variables + extra $args
as arguments. $args
will be evaluated using Variables::parseValue()
function. It will behave as normal Variable value.
Attention: Context returned closure does not accept any arguments.
Factory
A function to prevent your closue value from getting cached. Your closure will be called everytime value is accessed. $args
will be passed as arguments to closure function. $args
will be evaluated using Variables::parseValue()
function. It will behave as normal Variable value.
Will return a value which implements NonCacheableClosure
interface and prevents it from caching and behave as your normal closure.
All
A function to evaluate all values passed to arguments and return result as array.
Will return an array of all $args
evaluated.
Tip: To evaluate all values at variable get time use function: allFn(/* ... */)
.
Logic
A function to evaluate condition and decide which value to use. $condtion
, $true
, $false
are evaluated using Variables::parseValue()
function.
Will return a closure which will decide which $true
or $false
to return based on $condition
Attention: Logic returned closure does not accept any arguments.
Passthrough
A function which will pass all evaluted values as argumnents to closure.
Will return a closure which will pass $args
evaluated as arguments to Closure.
Attention: Passthrough returned closure does not accept any arguments.
First
A function which return a first truthfull value from arguments. $args
will be evaluated using Variables::parseValue()
function.
Tip: To evaluate at variable get time use function: firstFn(/* ... */)
.
Value Parsers
You can implement your own value parsers to be parsed when accessing variables value.
Testing
Run test cases
Run test cases with coverage (HTML format)
Run PHP style checker
Run PHP style fixer
Run all continuous integration tests
Contributing
Please see CONDUCT for details.
License
Please see License File for more information.