A basic singleton registry manager.
Carion is a simple singleton manager framework., (*1)
composer require wallaceosmar/carion-framework
The access of the values can be due to a object value or array access., (*2)
require_once './vendor/autoload.php'; $carion->example = 'example'; $carion['example2'] = 'example2'; echo $cation->example; echo $carion['example2'];
Singleton is used to call some functions or instantiate custom class., (*3)
$carion = new Carion\Carion(); $carion->singleton( 'example', function () { return 'example'; }); echo $carion->example;
The function singleton map the names of the paramter to a singleton register in the class., (*4)
$carion = new Carion\Carion(); $carion->set('value', 'example'); $carion->singleton( 'example', function ( $value ) { return $value; }); echo $carion->example;
If the does`t have a value to the paramter, will be seted null as the value., (*5)
$carion = new Carion\Carion(); $carion->singleton( 'example', function ( $value ) { if ( 'example' == $value ) { $value = md5( $value )'; } return $value; }); echo $carion->example;
You can call a function or a class method using the function call., (*6)
The function call is reponsibly to map all the paramters., (*7)
echo $carion->call(function( $value1, $value2 ) { return $value1 + $value2; }, array( 10, 20 ));
Parsing a array with key name overwrite the order of values., (*8)
echo $carion->call(function( $value1, $value2 ) { return $value1 + $value2; }, array( 10, 20, 'value1' => 0 ));