Beispiel #1
0
 public function testDeferredEvaluation()
 {
     $doubleOdds = new Container();
     $doubleOdds->filter('Dash\\Functions\\isOdd')->map(function ($n) {
         return $n * 2;
     });
     $this->assertEquals(array(2, 6), $doubleOdds->with(array(1, 2, 3))->value());
     $this->assertEquals(array(14, 18, 22, 26), $doubleOdds->with(array(7, 9, 11, 13))->value());
 }
Beispiel #2
0
 public function testNegateInChain()
 {
     $isPositive = function ($value) {
         return $value > 0;
     };
     $container = new Container(array(2, -3, 5, -8));
     $negatives = $container->filter(Functions\negate($isPositive))->values()->value();
     $this->assertEquals(array(-3, -8), $negatives);
 }