Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 /**
  * Factory Method for binary functors.
  *
  * @param callable $bifunctor
  * @return BinaryFunktionInterface
  */
 public static final function newBinaryFunktion(callable $funktion) : BinaryFunktionInterface
 {
     return BinaryFunktion::create($funktion);
 }