mamazu / partial-functions
Applying partial functions
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/mamazu/partial-functions
Requires
- php: ^7.3
Requires (Dev)
- mamazu/documentation-validator: ^1.2
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-12-20 23:17:46 UTC
README
This library provides a partial function interface for php.
Usage
The simpletest way to use it with the FunctionInvoker:
function f(string $greeting = 'Hello', string $name = 'you') { return $greeting.', '.$name; } echo \Mamazu\PartialFunctions\FunctionInvoker::invoke('f', ['name' => 'Anonymous']); // Will echo "Hello, Anonymous"
Object oriented
$factory = new \Mamazu\PartialFunctions\PartialFunctionFactory(); $searchInString = $factory->createForCallable('strpos'); $searchInString->apply(['haystack' => 'Hello in PHP']); $hellopos = $searchInString->call(['needle' => 'hello']); $phppos = $searchInString->call(['needle' => 'php']);