public function test_cycle_continue() { $arr = array(1, 2, 3); $count = 0; Enumerator::cycle($arr, 3, function ($key, $value, $it) use(&$count) { if ($value == 2 && $it == 1) { throw new ContinueException(); } $count += $value; }); $this->assertEquals(16, $count); }
public function test_cycle_1() { $i = 0; $arr = array(1, 2, 3); Enumerator::cycle($arr, 3, function ($key, $value, $it) use(&$i) { $i++; }); $this->assertEquals(9, $i); }