示例#1
0
 public function testFnPipeWithMultipleArgumentsInFirstFunction()
 {
     $fnAdd = function ($a, $b) {
         return $a + $b;
     };
     $fnIncrease = function ($v) {
         return $v + 1;
     };
     $fnChain = fn\fnPipe($fnAdd, $fnIncrease, $fnIncrease, $fnIncrease);
     $this->assertEquals(8, $fnChain(2, 3));
 }
示例#2
0
/**
 * Generates a function that pulls a value from a field in the document and passes it to $fnMap.
 * 
 * @param string $fieldName
 * @param Closure $fnMap($fieldValue)
 * @return Closure
 */
function fnMapFromField($fieldName, $fnMap)
{
    return fn\fnPipe(fn\fnPluck($fieldName), $fnMap);
}