Пример #1
0
 public function test_reduce()
 {
     $collection = new Collection(array(1, 2, 3, 4));
     $result = $collection->reduce(function ($result, $v) {
         return $result + $v;
     });
     $this->assertSame(10, $result, '1 + 2 + 3 + 4 = 10');
     $this->assertSame(array(1, 2, 3, 4), $collection->toArray(), 'Original array should remain intact');
 }