Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

mamazu/partial-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

partial-function application in php

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']);

About

An implementation of partial functions

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages