Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 92 | All time: 9,918 This week: 660 |
Version | License | PHP version | Categories | |||
action 1.0.0 | Custom (specified... | 7.1 | Language, PHP 7 |
Description | Author | ||||||||
This package can create objects that execute actions dynamically. |
|
This class intends to make programatic and dynamic functions calls.
To use the Action
class, just use the factory
method, to build a new object, passing the parameters to use on this function.
At the end, just execute the instance's exec
method, passing optionally the additional parameters.
The URI patterns you can use are:
| Type | Example | | --------------- | ---------------------- | | Simple function | 'mySampleFunction()' | | Class method | '\namespace\MyClass::functionName()' | | REST call* | 'POST;https://user!password@my_domain.com:8081/api/v99/xpto?v1=1&v2=2#xpto' |
Make a call to a global function.
function multiply($x,$y) {
return $x * $y;
}
$action = Action::factory('multiply()');
$response = $action->exec(2,5);
// result = 10
Instantiate a class object, and execute the assigned method.
If your class have a constructor method, and require any parameter, you can suply it on 3rd parameter of factory
method:
$action = Action::factory('MyClass::myFunction()',[],['constructor'=>[1,'string',false]]);
On above the case, the values 1
, 'string'
and false
will be applied on MyClass
constructor.
class MyClass {
public function myFunction($id, $fieldName) {
// ...
return [
'id' => $id,
'field_name'=> $fieldName
];
}
}
$action = Action::factory('MyClass::myFunction()', [1, 'name']);
$response = $action->exec();
print_r($response);
Will display:
Array
(
[id] => 1
[field_name] => name
)
Files (23) |
File | Role | Description | ||
---|---|---|---|---|
bin (1 file) | ||||
doc (1 file) | ||||
src (6 files, 1 directory) | ||||
tests-public (1 file) | ||||
tests-src (1 file) | ||||
tests (2 directories) | ||||
bootstrap.php | Aux. | Auxiliary script | ||
bootstrap_test.php | Aux. | Auxiliary script | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data |
Files (23) | / | src |
File | Role | Description | ||
---|---|---|---|---|
exception (2 files) | ||||
Action.php | Class | Class source | ||
ActionClassMethod.php | Class | Class source | ||
ActionRegularFunction.php | Class | Class source | ||
ActionRemoteAPICall.php | Class | Class source | ||
DBAccessible.php | Class | Class source | ||
Parameters.php | Class | Class source |
Files (23) | / | src | / | exception |
File | Role | Description |
---|---|---|
FunctionNotFoundException.php | Class | Class source |
InvalidURIException.php | Class | Class source |
Files (23) | / | tests | / | integration |
File | Role | Description |
---|---|---|
ActionRemoteAPICallTest.php | Class | Class source |
Files (23) | / | tests | / | unit |
File | Role | Description |
---|---|---|
ActionClassMethodTest.php | Class | Class source |
ActionRegularFunctionTest.php | Class | Class source |
ActionRemoteAPICallTest.php | Class | Class source |
ActionTest.php | Class | Class source |
ParametersTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.