public function testCompose()
 {
     $firstCallable = self::getCallable();
     $first = UnaryFunktion::create($firstCallable);
     $secondCallable = function ($value) {
         return $value + 1;
     };
     $second = UnaryFunktion::create($secondCallable);
     $composed = $first->compose($second);
     $a = rand(1, 100);
     $this->assertInstanceOf(UnaryFunktion::class, $composed);
     $this->assertEquals($secondCallable($firstCallable($a)), $composed->call($a));
 }
 public function testCompose()
 {
     $firstCallable = self::getCallable();
     $first = NaryPredicate::create($firstCallable);
     $secondCallable = function ($value) {
         return $value && true;
     };
     $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));
 }
Example #3
0
 /**
  * Factory Method for unary functors.
  *
  * @param callable $funktion
  * @return UnaryFunktionInterface
  */
 public static final function newUnaryFunktion(callable $funktion) : UnaryFunktionInterface
 {
     return UnaryFunktion::create($funktion);
 }