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