PHP code example of open-solid / callable-invoker
1. Go to this page and download the library: Download open-solid/callable-invoker library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
open-solid / callable-invoker example snippets
use OpenSolid\CallableInvoker\CallableInvoker;
class HelloHandler
{
public function __invoke(string $name, int $age = 30): string
{
return "Hello, $name! You are $age years old.";
}
}
$handler = new HelloHandler();
$invoker = new CallableInvoker();
$result = $invoker->invoke(callable: $handler, context: ['name' => 'Alice']);
echo $result; // Output: Hello, Alice! You are 30 years old.