An open API service indexing awesome lists of open source software.

https://github.com/krakphp/invoke

Invocation Abstraction Library
https://github.com/krakphp/invoke

Last synced: about 1 year ago
JSON representation

Invocation Abstraction Library

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);
```