public function testCompose() { $firstCallable = self::getCallable(); $first = NaryFunktion::create($firstCallable); $secondCallable = function ($value) { return $value + 1; }; $second = UnaryFunktion::create($secondCallable); $composed = $first->compose($second); $a = rand(1, 100); $b = rand(1, 100); $c = rand(1, 100); $d = rand(1, 100); $this->assertInstanceOf(NaryFunktion::class, $composed); $this->assertEquals($secondCallable($firstCallable($a, $b, $c, $d)), $composed->call($a, $b, $c, $d)); }
/** * Factory Method for generic functors. * * @param callable $funktion * @return NaryFunktionInterface */ public static final function newNaryFunktion(callable $funktion) : NaryFunktionInterface { return NaryFunktion::create($funktion); }