public function random($seed = null)
{
if (isset($seed)) {
mt_srand($seed);
}
return $this->elements[mt_rand(0, $this->length - 1)];
}
public function test_cycle() { $elements = array(1, 2, 3); $cycler = new Helper\Cycler($elements); $this->assertTrue($cycler instanceof \IteratorAggregate); $this->assertEquals(1, $cycler->next()); $this->assertEquals(2, $cycler->next()); $this->assertEquals(3, $cycler->next()); $this->assertTrue(in_array($cycler->random(), $elements)); }