https://github.com/krakphp/invoke
Invocation Abstraction Library
https://github.com/krakphp/invoke
Last synced: about 1 year ago
JSON representation
Invocation Abstraction Library
- Host: GitHub
- URL: https://github.com/krakphp/invoke
- Owner: krakphp
- License: mit
- Created: 2017-03-19T02:39:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-07T20:25:30.000Z (almost 9 years ago)
- Last Synced: 2025-03-05T13:07:54.011Z (over 1 year ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Invoke
Simple abstractions for invoking functions with parameters.
## Installation
Install with composer at `krak/invoke`
## Usage
Each invoker implements the simple interface:
```php
invoke('hello', 'World');
```
### Container Invoke
```php
invoke('service'); // will invoke the function returned from the container
$invoke->invoke('str_repeat', 'a', 10); // if not in container, will try to normally invoke
```
#### Container with Separator
In addition to just invoking services, you can invoke service object methods if you pass in a separator into the container factory method.
```php
invoke('service@count'); // retrieves the service and invokes the count method which outputs 1 in this case
```
### Method Invoke
```php
invoke($data, 1);
$invoke->invoke($data, 2);
assert(count($data) == 2);
```